-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ability to skip files or blocks entirely #10220
Comments
FWIW, just building the code takes less than 30 seconds additional, so it’s not just a matter of Rust taking a long time with a lot of code. |
What commands should one use to reproduce the 20+ minute run? (When I just |
iter-matcher just generates code, it doesn’t build it. I published a branch on another crate to demonstrate. I'll try to keep it clean, but this is all under active development.
|
Based on a cursory analysis, this appears to be where the time is spent:
These line numbers are with respect to the latest nightly (e0ee58b). This is an area of code actively being worked on for other reasons (see #10134). Hopefully, we'll have a fix soon. (cc: @Jarcho) |
In the meanwhile, clippy does pass |
@Alexendoo that works, thanks! (FWIW, it would have to pass I guess all that remains is documenting it somewhere. I’ll try to take a crack at that in the next few days (if nobody beats me to it). |
It is possible to use conditional compilation to prevent Clippy from evaluating certain code at all. Unfortunately, it was no longer documented anywhere. This adds a brief explanation of how to use the feature with conditional compilation, and mentions a few downsides. Fixes #rust-lang#10220 — Ability to skip files or blocks entirely
It is possible to use conditional compilation to prevent Clippy from evaluating certain code. This adds a brief explanation of how to use the feature with conditional compilation, and mentions that generally it’s preferable to use something like `#[allow(clippy::all)]`. Fixes rust-lang#10220 — Ability to skip files or blocks entirely
I’ve renamed the iter-matcher crate to matchgen, so here are the new instructions for reproducing the slow Clippy behavior:
It took 22 minutes on my machine. This generates code with I figure that a function that’s tens of thousands of lines long isn’t a very high priority, but I’ll reinvestigate and possibly produce a minimal test case once #10134 is finished. (This can’t be the same issue because it’s in stable Clippy, but it sounds like it may be in code that’s going to be significantly changed anyway.) |
Document `cargo-clippy` feature It is possible to use conditional compilation to prevent Clippy from evaluating certain code at all. Unfortunately, it was no longer documented anywhere. This adds a brief explanation of how to use the feature with conditional compilation, and mentions a few downsides. Fixes #10220 — Ability to skip files or blocks entirely changelog: none <!-- changelog_checked -->
It is possible to use conditional compilation to prevent Clippy from evaluating certain code. This adds a brief explanation of how to use the feature with conditional compilation, and mentions that generally it’s preferable to use something like `#[allow(clippy::all)]`. Fixes rust-lang#10220 — Ability to skip files or blocks entirely
Description
Some experimental code of mine generates a 48,000+ line function1 that takes 20+ minutes to process with
Clippy
with all lints allowed.It would be really helpful to be able to skip or ignore files or blocks of code entirely.
This seems like a fairly niche use-case, so perhaps this isn’t worth pursuing.
Discarded idea: using a feature
I considered adding a
clippy
feature, but this is a bit inconvenient. I usually runcargo clippy --all-features
so hiding the code iffeature = "clippy"
works well, but I also runcargo test --all-features
so I need to change one or the other. This is additionally complicated by needing to configure CI correctly.These are not insurmountable problems at all, but they do make it harder, especially for new people who want to contribute to my project.
Proposal: setting
--cfg clippy
when Clippy runsCode that you don’t want Clippy to look at could be guarded with
#[cfg(not(clippy))]
.I haven’t dug into the Clippy code yet, but this seems like it might be relatively easy to implement (I’m happy to volunteer).
I’m not sure if Clippy would need an option to disable the configuration option so that you can force it to look at all code. For my usage, I would be happy to just remove the
#[cfg(not(clippy))]
line and run clippy again, but I could imagine that some people would want to run Clippy on some code only some times.I suppose another solution would be for
cargo clippy
to accept--cfg
options.Version
Additional Labels
@rustbot label +C-enhancement
Footnotes
The code is actually used in a private branch on another crate, but there is an example that generates the function. This is all a bit horrific, and I’m still considering just shelving the idea, but it’s much faster than anything else I’ve tried. ↩
The text was updated successfully, but these errors were encountered: