You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asomers opened this issue
Oct 16, 2021
· 2 comments
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
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.
Also, checking for invalid target_env would be good. I just discovered some code that was wrongly checking for target_env = "newlibc" instead of target_env = "newlib".
Hey, thank you for the suggestion. In general, it could be nice to check for valid targets etc.
The current API of rustc(which Clippy uses) sadly doesn't really support lints that check code before the expansion of macros. At one point, we want to have some kind of interface to also lint macros, like in this example. For now, I'll add the blocked label until we find a good way to handle macros 🙃
xFrednet
added
S-blocked
Status: marked as blocked ❌ on something else such as an RFC or other implementation work
T-macros
Type: Issues with macros and macro expansion
labels
Oct 17, 2021
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
What it does
Checks if the value used with
#[cfg(target_arch = "XXX")]
is valid.Categories (optional)
For example:
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
Should be written as:
The text was updated successfully, but these errors were encountered: