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 clippy into the known cfg list #121137

Merged
merged 4 commits into from Feb 16, 2024
Merged

Conversation

GuillaumeGomez
Copy link
Member

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

@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2024

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 15, 2024
@@ -1441,6 +1441,7 @@ impl CheckCfg {
// These three are never set by rustc, but we set them anyway: they
// should not trigger a lint because `cargo doc`, `cargo test`, and
// `cargo miri run` (respectively) can set them.
ins!(sym::clippy, no_values);
Copy link
Contributor

Choose a reason for hiding this comment

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

It needs to be added in tests/ui/check-cfg/well-known-values.rs.

You will also probably need to bless the directory

@rust-log-analyzer

This comment has been minimized.

@@ -1441,6 +1441,7 @@ impl CheckCfg {
// These three are never set by rustc, but we set them anyway: they
// should not trigger a lint because `cargo doc`, `cargo test`, and
// `cargo miri run` (respectively) can set them.
ins!(sym::clippy, no_values);
Copy link
Contributor

Choose a reason for hiding this comment

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

The check-cfg section of the unstable book also needs updating:

As of `2024-01-09T`, the list of known names is as follows:
<!--- See CheckCfg::fill_well_known in compiler/rustc_session/src/config.rs -->
- `debug_assertions`
- `doc`
- `doctest`
- `miri`

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member

Choose a reason for hiding this comment

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

The code here should have a comment mentioning the docs :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding it.

@@ -81,6 +81,7 @@ As of `2024-01-09T`, the list of known names is as follows:

<!--- See CheckCfg::fill_well_known in compiler/rustc_session/src/config.rs -->

- `clippy`
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great if you could also update the date above to 2024-02-15T

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@@ -106,4 +106,7 @@ fn unix() {}
#[cfg(doc)]
fn doc() {}

#[cfg(clippy)]
fn clippy() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add the cfg above as to check that we only expect clippy and nothing else.

 #[cfg(any(
     // tidy-alphabetical-start
+    clippy = "_UNEXPECTED_VALUE",
+    //~^ WARN unexpected `cfg` condition value
     debug_assertions = "_UNEXPECTED_VALUE",
     //~^ WARN unexpected `cfg` condition value

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah sure.

@GuillaumeGomez
Copy link
Member Author

Updated! Thanks a lot for the reviews!

@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@Urgau Urgau left a comment

Choose a reason for hiding this comment

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

Looks good, thanks.

Comment on lines 1442 to 1443
// should not trigger a lint because `cargo doc`, `cargo test`,
// `cargo clippy` and `cargo miri run` (respectively) can set them.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
// should not trigger a lint because `cargo doc`, `cargo test`,
// `cargo clippy` and `cargo miri run` (respectively) can set them.
// should not trigger a lint because `cargo clippy`, `cargo doc`,
// `cargo test` and `cargo miri run` (respectively) can set them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, let's alpha sort them. 😆

@GuillaumeGomez
Copy link
Member Author

r? @compiler-errors

@rustbot rustbot assigned compiler-errors and unassigned TaKO8Ki Feb 15, 2024
@Nilstrieb
Copy link
Member

Guillaume asked me to review the PR since I commented on it, and it looks good to me.
@bors r=Urgau,Nilstrieb

@bors
Copy link
Contributor

bors commented Feb 15, 2024

📌 Commit 533e3f0 has been approved by Urgau,Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2024
@flip1995
Copy link
Member

@bors rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 16, 2024
…llaumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#119928 (suggest `into_iter()` when `Iterator` method called on `impl IntoIterator`)
 - rust-lang#121020 (Avoid an ICE in diagnostics)
 - rust-lang#121111 (For E0038, suggest associated type if available)
 - rust-lang#121137 (Add clippy into the known `cfg` list)
 - rust-lang#121179 (allow mutable references in const values when they point to no memory)
 - rust-lang#121181 (Fix an ICE in the recursion lint)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f60576b into rust-lang:master Feb 16, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 16, 2024
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`
@GuillaumeGomez GuillaumeGomez deleted the add-clippy-cfg branch February 17, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants