-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed as not planned
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
The deprecated_clippy_cfg_attr lint does not seem to work in generated code. I have confirmed that other lints are working, and that the lint works on code in src/lib.rs.
Reference: PR #12292 — Add new lint DEPRECATED_CLIPPY_CFG_ATTR.
Lint Name
deprecated_clippy_cfg_attr
Reproducer
-
cargo init . --name foo --lib -
build.rs:
fn main() { std::fs::write( std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).join("foo.rs"), r#" pub fn lint() { // Correct: Clippy will catch this. if 100 > i32::MAX {} } // INCORRECT: Clippy will not lint this. #[cfg(not(feature = "cargo-clippy"))] pub fn no_lint() { // Correct: Clippy will ignore this. if 200 > i32::MAX {} } "#, ) .unwrap(); }
-
src/lib.rs:
include!(concat!(env!("OUT_DIR"), "/foo.rs")); // Correct: Clippy will catch this. #[cfg(not(feature = "cargo-clippy"))] pub fn reference() { // Correct: Clippy will ignore this. if 300 > i32::MAX {} }
Actual results
❯ cargo +nightly clippy --message-format short
Checking foo v0.1.0 (/...)
src/lib.rs:4:11: warning: `feature = "cargo-clippy"` was replaced by `clippy`
/.../target/debug/build/.../out/foo.rs:4:8: error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
warning: `foo` (lib) generated 1 warning
error: could not compile `foo` (lib) due to 1 previous error; 1 warning emitted
This catches the use of feature = "cargo-clippy" in src/lib.rs, and one of the comparisons in the generated code, but does not warn about the use of feature = "cargo-clippy" in the generated code.
Expected results
❯ cargo +nightly clippy --message-format short
Checking foo v0.1.0 (/...)
src/lib.rs:4:11: warning: `feature = "cargo-clippy"` was replaced by `clippy`
/.../target/debug/build/.../out/foo.rs:4:8: error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
/.../target/debug/build/.../out/foo.rs:8:11: warning: `feature = "cargo-clippy"` was replaced by `clippy`
warning: `foo` (lib) generated 1 warning
error: could not compile `foo` (lib) due to 1 previous error; 1 warning emitted
Version
rustc 1.78.0-nightly (c475e2303 2024-02-28)
binary: rustc
commit-hash: c475e2303b551d726307c646181e0677af1e0069
commit-date: 2024-02-28
host: x86_64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Type
Fields
Give feedbackNo fields configured for issues without a type.