Skip to content

Check for invalid target_arch #7828

Open
@asomers

Description

@asomers

What it does

Checks if the value used with #[cfg(target_arch = "XXX")] is valid.

Categories (optional)

  • Kind: correctness

For example:

  • Detects dead code that almost certainly shouldn't be dead

Drawbacks

Might not be forwards-compatible with architectures added by future compilers. For example, if Rust 1.75.0 adds support for itanium and a crate cfg-gates on that, Clippy 1.74.0 would falsely warn about it.

Example

A real-world example from the Nix crate: nix-rust/nix#1566

#[cfg(target_arch = "ppc")]
pub struct Foo{}

Should be written as:

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub struct Foo{}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsS-blockedStatus: marked as blocked ❌ on something else such as an RFC or other implementation workT-macrosType: Issues with macros and macro expansion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions