-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add new lint DEPRECATED_CLIPPY_CFG_ATTR
#12292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f35eec8
e0f82af
cd6f03a
f4a3db8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,7 +271,9 @@ pub fn main() { | |
}, | ||
_ => Some(s.to_string()), | ||
}) | ||
// FIXME: remove this line in 1.79 to only keep `--cfg clippy`. | ||
.chain(vec!["--cfg".into(), r#"feature="cargo-clippy""#.into()]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Urgau Can I ask you to remove this line as part of the stabilization PR of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, no problem. |
||
.chain(vec!["--cfg".into(), "clippy".into()]) | ||
flip1995 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.collect::<Vec<String>>(); | ||
|
||
// We enable Clippy if one of the following conditions is met | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![warn(clippy::deprecated_clippy_cfg_attr)] | ||
#![allow(clippy::non_minimal_cfg)] | ||
#![cfg_attr(clippy, doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was | ||
|
||
#[cfg_attr(clippy, derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg_attr(not(clippy), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(clippy)] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(not(clippy))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(any(clippy))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(all(clippy))] //~ ERROR: `feature = "cargo-clippy"` was | ||
pub struct Bar; | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![warn(clippy::deprecated_clippy_cfg_attr)] | ||
#![allow(clippy::non_minimal_cfg)] | ||
#![cfg_attr(feature = "cargo-clippy", doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was | ||
|
||
#[cfg_attr(feature = "cargo-clippy", derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(feature = "cargo-clippy")] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(not(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(any(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was | ||
#[cfg(all(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was | ||
pub struct Bar; | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
error: `feature = "cargo-clippy"` was replaced by `clippy` | ||
--> $DIR/cfg_attr_cargo_clippy.rs:5:12 | ||
| | ||
LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | ||
| | ||
= note: `-D clippy::deprecated-clippy-cfg-attr` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::deprecated_clippy_cfg_attr)]` | ||
|
||
error: `feature = "cargo-clippy"` was replaced by `clippy` | ||
--> $DIR/cfg_attr_cargo_clippy.rs:6:16 | ||
| | ||
LL | #[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | ||
|
||
error: `feature = "cargo-clippy"` was replaced by `clippy` | ||
--> $DIR/cfg_attr_cargo_clippy.rs:7:7 | ||
| | ||
LL | #[cfg(feature = "cargo-clippy")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | ||
|
||
error: `feature = "cargo-clippy"` was replaced by `clippy` | ||
--> $DIR/cfg_attr_cargo_clippy.rs:8:11 | ||
| | ||
LL | #[cfg(not(feature = "cargo-clippy"))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | ||
|
||
error: `feature = "cargo-clippy"` was replaced by `clippy` | ||
--> $DIR/cfg_attr_cargo_clippy.rs:9:11 | ||
| | ||
LL | #[cfg(any(feature = "cargo-clippy"))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | ||
|
||
error: `feature = "cargo-clippy"` was replaced by `clippy` | ||
--> $DIR/cfg_attr_cargo_clippy.rs:10:11 | ||
| | ||
LL | #[cfg(all(feature = "cargo-clippy"))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | ||
|
||
error: `feature = "cargo-clippy"` was replaced by `clippy` | ||
--> $DIR/cfg_attr_cargo_clippy.rs:3:13 | ||
| | ||
LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | ||
|
||
error: aborting due to 7 previous errors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible enhancement to this lint could be to check if the second part of the
cfg_attr
is anallow
/warn
/... and suggest to remove thecfg_attr
completely.OTOH we might want to add an extra lint for this, once people moved to
cfg_attr(clippy, allow(...))
.So I wouldn't do this in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the same suggestion to @GuillaumeGomez in private and we also thought that it would be better done in a follow-up, as to also catch the pattern with
cfg_attr(clippy, ...)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm we did. ;)
I'll likely send a follow-up PR.