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

Always print lints from plugins, if they're available #77671

Merged
merged 6 commits into from
Nov 26, 2020

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented Oct 7, 2020

Currently you can get a list of lints and lint groups by running rustc -Whelp. This prints an additional line at the end:

Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename.

Clippy is such a "compiler plugin", that provides additional lints.
Running clippy-driver -Whelp (rustc wrapper) still only prints the
rustc lints with the above message at the end. But when running
clippy-driver -Whelp main.rs, where main.rs is any rust file, it
also prints Clippy lints. I don't think this is a good approach from a
UX perspective: Why is a random file necessary to print a help message?

This PR changes this behavior: Whenever a compiler callback
registers lints, it is assumed that these lints come from a plugin and
are printed without having to specify a Rust source file.

Fixes rust-lang/rust-clippy#6122

cc @Manishearth @ebroto for the Clippy changes.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 7, 2020
@Manishearth
Copy link
Member

r+ on making this happen, I'll let eddy review the PR (though i should be able to if i get time)

Copy link
Member

@ebroto ebroto left a comment

Choose a reason for hiding this comment

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

Clippy part LGTM 👍

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 24, 2020

☔ The latest upstream changes (presumably #79228) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

Currently you can get a list of lints and lint groups by running `rustc
-Whelp`. This prints an additional line at the end:
```
Compiler plugins can provide additional lints and lint groups. To see a
listing of these, re-run `rustc -W help` with a crate filename.
```

Clippy is such a "compiler plugin", that provides additional lints.
Running `clippy-driver -Whelp` (`rustc` wrapper) still only prints the
rustc lints with the above message at the end. But when running
`clippy-driver -Whelp main.rs`, where `main.rs` is any rust file, it
also prints Clippy lints. I don't think this is a good approach from a
UX perspective: Why is a random file necessary to print a help message?

This commit changes this behavior: Whenever a compiler callback
registers lints, it is assumed that these lints come from a plugin and
are printed without having to specify a Rust source file.
Also stop updating the lintlist module in clippy_dev update_lints
@flip1995
Copy link
Member Author

@eddyb @Manishearth This PR is 1 1/2 months old and waiting for review. This would be nice to have from a Clippy perspective.

@lnicola
Copy link
Member

lnicola commented Nov 24, 2020

For more context, it's also useful for rust-analyzer because it can use it to offer completions for #[allow] and #[deny] attributes.

@flip1995
Copy link
Member Author

For more context, it's also useful for rust-analyzer because it can use it to offer completions for #[allow] and #[deny] attributes.

Oh right, that's why I did this in the first place. I already forgot lol 😄

"Compiler plugins can provide additional lints and lint groups. To see a \
listing of these, re-run `rustc -W help` with a crate filename."
);
println!("Compiler plugins can provide additional lints and lint groups.");
Copy link
Member

Choose a reason for hiding this comment

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

let's actually just get rid of this? It's not relevant to clippy, and compiler plugins are not a common thing.

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 reworded it in e54c060. Removing this would also involve dealing with this case in the match statement somehow. I think printing a message, that tools can provide more lints is a good way to deal with this case.

@@ -1,2942 +0,0 @@
//! This file is managed by `cargo dev update_lints`. Do not edit or format this file.
Copy link
Member

Choose a reason for hiding this comment

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

YAY

@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2020

@bors r=oli-obk,Manishearth

@bors
Copy link
Contributor

bors commented Nov 26, 2020

📌 Commit e54c060 has been approved by oli-obk,Manishearth

@bors
Copy link
Contributor

bors commented Nov 26, 2020

🌲 The tree is currently closed for pull requests below priority 500, this pull request will be tested once the tree is reopened

@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 Nov 26, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2020

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned eddyb Nov 26, 2020
@bors
Copy link
Contributor

bors commented Nov 26, 2020

⌛ Testing commit e54c060 with merge 72da5a9...

@bors
Copy link
Contributor

bors commented Nov 26, 2020

☀️ Test successful - checks-actions
Approved by: oli-obk,Manishearth
Pushing 72da5a9 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 26, 2020
@bors bors merged commit 72da5a9 into rust-lang:master Nov 26, 2020
@rustbot rustbot added this to the 1.50.0 milestone Nov 26, 2020
@flip1995 flip1995 deleted the lint_list_always_plugins branch November 27, 2020 08:57
flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 6, 2020
…oli-obk,Manishearth

Always print lints from plugins, if they're available

Currently you can get a list of lints and lint groups by running `rustc
-Whelp`. This prints an additional line at the end:
```
Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename.
```

Clippy is such a "compiler plugin", that provides additional lints.
Running `clippy-driver -Whelp` (`rustc` wrapper) still only prints the
rustc lints with the above message at the end. But when running
`clippy-driver -Whelp main.rs`, where `main.rs` is any rust file, it
also prints Clippy lints. I don't think this is a good approach from a
UX perspective: Why is a random file necessary to print a help message?

This PR changes this behavior: Whenever a compiler callback
registers lints, it is assumed that these lints come from a plugin and
are printed without having to specify a Rust source file.

Fixes rust-lang/rust-clippy#6122

cc `@Manishearth` `@ebroto` for the Clippy changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo clippy -- -W help runs clippy
9 participants