-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
rust-lang/rust
#77671Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thinggood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
cargo clippy -- -W help
seems to runclippy
, so it takes a while on a first build and, of course, it requires a project. Would it be possible to print the available lints and quit, similar torustc -W help
?
Context: in
rust-analyzer
we'd like to offer code completions for the various lints, but the only way to get them is to download http://rust-lang.github.io/rust-clippy/master/lints.json.
Originally posted by @lnicola in #5385 (comment)
Even though the -Whelp
thing is unstable, it shouldn't have to run Clippy on a crate to print out the help message with all lints.
lnicola
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thinggood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Activity
bnjjj commentedon Oct 6, 2020
Will take a look to fix that as a first contribution to clippy :)
do not run clippy for rust-lang#6122
do not run clippy for cargo clippy -- -W help rust-lang#6122
do not run clippy for cargo clippy -- -W help rust-lang#6122
flip1995 commentedon Oct 6, 2020
@lnicola You can get the list of clippy lints with
clippy-driver -W help
(-Whelp
w/o whitespace, just prints the rustc lints). Runningcargo clippy -- -W help
is like runningcargo rustc -- -W help
, except that Clippy has an (unwanted?) hack, that this works. So the current behavior is kind of intentional. Only theclippy-driver -W help
version is expected to work.@bnjjj asked about adding a flag to display the lint list in
json
format. We could think about something like that. I will start a discussion about this on Zulip, but this issue is not really an issue.@bnjjj Thanks for your work! Even though your PR won't get merged, it helped to figure out what is going on and is therefore much appreciated! If you want to improve the situation with
clippy-driver -W help
, we could try to not handle-Whelp
at all indriver.rs
, but just pass it along with the other flags to rustc and let it handle by rustc. It works for-Wlint_name
, so it might also work for-Whelp
🤷Also this message at the end of the output of
rustc -Whelp
suggests, that it might work:ebroto commentedon Oct 7, 2020
The problem I see with that approach is that it requires providing a crate, while the manual handling of
-W help
does not. It seems that the request to print all the lints is not processed until after parsing, see here. This is probably related to the plugin interface, which has not been removed yet AFAIK.(pointing this out because it was one of the concerns in the OP)
flip1995 commentedon Oct 7, 2020
Yeah, I wondered why and went investigating. Because from a UX perspective it doesn't make sense, that
clippy-driver -W help
prints rustc lints andclippy-driver -W help main.rs
prints rustc and Clippy lints. (And it doesn't require a crate in the cargo sense, but in the rustc/AST sense, so some dummy rust file)I found this code snippet, which is executed if
rustc
is called without an input file:https://github.com/rust-lang/rust/blob/98edd1fbf8a68977a2a7c1312eb1ebff80515a92/compiler/rustc_driver/src/lib.rs#L209-L213
We could easily modify this with
which then should always print all lints, if there is a plugin (or something else that registers lints).
Auto merge of rust-lang#77671 - flip1995:lint_list_always_plugins, r=…
Auto merge of #77671 - flip1995:lint_list_always_plugins, r=oli-obk,M…
forbid(clippy::undocumented_unsafe_blocks)
crates differently geiger-rs/cargo-geiger#247