Skip to content
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

Add new lint DEPRECATED_CLIPPY_CFG_ATTR #12292

Merged
merged 4 commits into from
Feb 16, 2024

Conversation

GuillaumeGomez
Copy link
Member

As discussed on zulip.

This lint suggests to replace feature = "cargo-clippy" with clippy.

r? @flip1995

changelog: Add new lint DEPRECATED_CLIPPY_CFG_ATTR

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 14, 2024
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impl LGTM. 2 open questions.

I think we want to wait with merging this, until cfg(clippy) is known by rustc/cargo? Then we'll also add --cfg clippy to the clippy-driver.

clippy_lints/src/attrs.rs Outdated Show resolved Hide resolved
clippy_lints/src/attrs.rs Show resolved Hide resolved
@Urgau
Copy link
Member

Urgau commented Feb 14, 2024

I think we want to wait with merging this, until cfg(clippy) is known by rustc/cargo?

We can do it at the same time. It won't be an issue until clippy is synced in rust-lang/rust.
It will also probably be easier to convince rust-lang/rust folks if this PR is merged first.

@GuillaumeGomez GuillaumeGomez force-pushed the DEPRECATED_CLIPPY_CFG_ATTR branch 3 times, most recently from 7f1e19f to 22cd0dd Compare February 14, 2024 22:40
@GuillaumeGomez
Copy link
Member Author

Finally fixed doc test and dogfood. ^^'

@flip1995
Copy link
Member

It won't be an issue until clippy is synced in rust-lang/rust.

That's in exactly one week. Will rustc be ready until then. I'd rather approve the PR and leave it as S-blocked until rustc is ready. I'm happy to do an out of cycle sync for this. We need to get all of those changes in, in the same release cycle. Just merging and hoping that rustc (or any other OSS project) is ready in time doesn't work out great in my experience 😅

@GuillaumeGomez
Copy link
Member Author

Sending the PR for rust in a few minutes.

@GuillaumeGomez
Copy link
Member Author

Opened rust-lang/rust#121137.

tests/ui/useless_attribute.fixed Outdated Show resolved Hide resolved
src/driver.rs Show resolved Hide resolved
tests/ui/useless_attribute.stderr Outdated Show resolved Hide resolved
@Urgau
Copy link
Member

Urgau commented Feb 15, 2024

It won't be an issue until clippy is synced in rust-lang/rust.

That's in exactly one week. Will rustc be ready until then. I'd rather approve the PR and leave it as S-blocked until rustc is ready. I'm happy to do an out of cycle sync for this. We need to get all of those changes in, in the same release cycle. Just merging and hoping that rustc (or any other OSS project) is ready in time doesn't work out great in my experience 😅

-Zcheck-cfg is unstable and opt-in, so we have technically more than a week, but yes, I had planned to submit the PR just after this one merged; as to get them in the same-ish nightly.

Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and approved.

The last open question is, if this should be an extra lint or if it should be merged into DEPRECATED_CFG_ARG?

Comment on lines +895 to +896
"replace with",
"clippy".to_string(),
Copy link
Member

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 an allow/warn/... and suggest to remove the cfg_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.

Copy link
Member

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, ...).

Copy link
Member Author

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.

@flip1995
Copy link
Member

-Zcheck-cfg is unstable and opt-in

I would propose to keep -Zcheck-cfg unstable for at least one more release cycle after this PR and the cfg(clippy) PR in rustc are merged and synced. I'm not sure what timeline you have in mind for stabilization though.

@Urgau
Copy link
Member

Urgau commented Feb 16, 2024

No problem, I have not yet proposed stabilization of the feature. We are currently running a Call for Testing, we may run it for a second week, after that and if all goes well, I will propose stabilization in rustc and Cargo, I expect this to take several weeks; and will make sure to have at least one full release for cfg(clippy).

@@ -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()])
Copy link
Member

Choose a reason for hiding this comment

The 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 -Zcheck-cfg feature in rust-lang/rust please? That way, the time people have to transition is as long as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem.

@flip1995
Copy link
Member

The last open question is, if this should be an extra lint or if it should be merged into DEPRECATED_CFG_ARG?

Answering my final question myself:

After thinking about this, I prefer to use a new lint for this, because:

  • People that allowed the old DEPRECATED_CFG_ARG lint for some reason, still get a warning with the new lint
  • It will be easier for people to transition with cargo clippy --fix -- -Aclippy::all -Wclippy::deprecated_clippy_cfg_arg, without interfering with the old lint.

With that and as the cfg(clippy) PR is already in the bors queue:

@bors r+

@bors
Copy link
Contributor

bors commented Feb 16, 2024

📌 Commit f4a3db8 has been approved by flip1995

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 16, 2024

⌛ Testing commit f4a3db8 with merge 32c006c...

@bors
Copy link
Contributor

bors commented Feb 16, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 32c006c to master...

@bors bors merged commit 32c006c into rust-lang:master Feb 16, 2024
8 checks passed
@GuillaumeGomez GuillaumeGomez deleted the DEPRECATED_CLIPPY_CFG_ATTR branch February 16, 2024 10:35
@Urgau
Copy link
Member

Urgau commented Feb 16, 2024

Thank you @flip1995 (and @GuillaumeGomez) for your help, I really appreciate it ❤️.

Without your help this issue could very well have delayed check-cfg or even put it in limbo. Thank you very much.

@GuillaumeGomez
Copy link
Member Author

It allows me to take a break from some compiler stuff so it's very welcome. 😄

@flip1995
Copy link
Member

rust-lang/blog.rust-lang.org#1253

I thought I'd write a blog post about this.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 16, 2024
…rgau,Nilstrieb

Add clippy into the known `cfg` list

In clippy, we are removing the `feature = "cargo-clippy"` cfg to replace it with `clippy` in rust-lang/rust-clippy#12292. But for it to work, we need to declare `clippy` as cfg. It makes it more coherent with other existing tools like rustdoc.

cc `@flip1995`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 16, 2024
Rollup merge of rust-lang#121137 - GuillaumeGomez:add-clippy-cfg, r=Urgau,Nilstrieb

Add clippy into the known `cfg` list

In clippy, we are removing the `feature = "cargo-clippy"` cfg to replace it with `clippy` in rust-lang/rust-clippy#12292. But for it to work, we need to declare `clippy` as cfg. It makes it more coherent with other existing tools like rustdoc.

cc `@flip1995`
bors added a commit that referenced this pull request Feb 22, 2024
…ip1995

Add `unnecessary_clippy_cfg` lint

Follow-up of #12292.

r? `@flip1995`

changelog: Add `unnecessary_clippy_cfg` lint
danielparks added a commit to danielparks/matchgen that referenced this pull request Feb 28, 2024
`cfg(feature = "cargo-clippy")` has been [deprecated]. The correct way
to achieve the same result is now `cfg(clippy)`.

[deprecated]: rust-lang/rust-clippy#12292
danielparks added a commit to danielparks/matchgen that referenced this pull request Jun 18, 2024
`cfg(feature = "cargo-clippy")` has been [deprecated]. The correct way
to achieve the same result is now `cfg(clippy)`.

[deprecated]: rust-lang/rust-clippy#12292
bors added a commit that referenced this pull request Aug 29, 2024
…flip1995

Remove `feature=cargo-clippy` argument

Roses are red,
Violets are blue,
Fixme was written,
And now it's due

---

changelog: **Important Change** Removed the implicit `cargo-clippy` feature set by Clippy as announced here: <https://blog.rust-lang.org/2024/02/28/Clippy-deprecating-feature-cargo-clippy.html>
[#13246](#13246)

Follow-up of: #12292

r? `@flip1995`

cc: `@GuillaumeGomez`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants