Clippy lints / Suspicious
Clippy lint · Suspicious · checked with Clippy 0.1.99
clippy::deprecated_clippy_cfg_attr: `feature = "cargo-clippy"` was replaced by `clippy`
What it meansChecks for #[cfg_attr(feature = "cargo-clippy", ...)] and for #[cfg(feature = "cargo-clippy")] and suggests to replace it with #[cfg_attr(clippy, ...)] or #[cfg(clippy)]. It is in the suspicious group and warns by default.
What you see
warning: `feature = "cargo-clippy"` was replaced by `clippy` --> main.rs:3:7 | 3 | #[cfg(feature = "cargo-clippy")] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | = help: for further information visit https://rust-lang.github.io/rust-clippy/stable/index.html#deprecated_clippy_cfg_attr = note: `#[warn(clippy::deprecated_clippy_cfg_attr)]` on by default
Real output of Clippy 0.1.99 (Rust 1.99) on the example below. Names and line numbers in yours will differ.
Does it matter?
This feature has been deprecated for years and shouldn’t be used anymore.
Code that is most likely wrong or useless. Warns by default.
How to fix it
Clippy can fix this one for you: run cargo clippy --fix (add --allow-dirty if you have uncommitted changes). Review the diff before you commit.
Flagged
#[cfg(feature = "cargo-clippy")]
struct Bar;
Write this instead
#[cfg(clippy)]
struct Bar;
Turn it off, or on
Allow it where it does not fit your code, as narrowly as you can:
On one item
#[allow(clippy::deprecated_clippy_cfg_attr)]
fn my_function() { /* ... */ }Whole crate (Cargo.toml)
[lints.clippy]
deprecated_clippy_cfg_attr = "allow"One run
cargo clippy -- -A clippy::deprecated-clippy-cfg-attrThe [lints] table needs Rust 1.74 or newer. In a workspace, put it under [workspace.lints.clippy] and add [lints] workspace = true to each member.
Clippy's own documentation
What it does
Checks for #[cfg_attr(feature = "cargo-clippy", ...)] and for
#[cfg(feature = "cargo-clippy")] and suggests to replace it with
#[cfg_attr(clippy, ...)] or #[cfg(clippy)].
Why is this bad?
This feature has been deprecated for years and shouldn’t be used anymore.
Example
#[cfg(feature = "cargo-clippy")]
struct Bar;
Use instead:
#[cfg(clippy)]
struct Bar;
From the Clippy lint list (0.1.99), part of the Rust project, MIT or Apache-2.0. Official entry.
Related lints
- crate_in_macro_def`crate` references the macro call's crate
- crosspointer_transmuteChecks for transmutes between a type T and *T
- declare_interior_mutable_constnamed constant with interior mutability
- doc_nested_refdefslink reference defined in list item
- doc_suspicious_footnoteslooks like a footnote ref, but has no matching footnote
- drop_non_dropcall to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes
All 847 Clippy lints · Rust compiler errors · Cargo.toml checker
Up next
Related lintclippy::crate_in_macro_def`crate` references the macro call's crateRead it next →Did this answer your question?