-
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
Can clippy-driver
be always used as replacement of rustc
?
#8035
Comments
Hey, I have not worked on Rustc uses a query system for compilation, which enables incremental builds. Clippy reuses this infrastructure and only registers new lint passes for Clippy lints. The lexer, parser, type checker etc. are the same. Meaning that until then everything should be equal. This structure also means that errors during the code generation would not be caught by running Does this answer your question? 🙃 |
|
Yeah, exactly what @bjorn3 says. For context, I am asking this to see if, in the kernel, we can rely on For instance, does the following change codegen that Lines 115 to 119 in 3720735
A more general question is whether Clippy could be integrated into |
Yes. It will disable all optimizations done on the MIR. This means that LLVM has more work to do, but it also disables a couple of optimizations for patterns that LLVM is currently unable to optimize well. |
That is what I was afraid of... :( Opened #8037 to document this -- please take a look. If later on the guarantee can be made, then it can be removed. |
I was under the impression, that Clippy doesn't even do CG. It shouldn't be necessary, because Clippy has no lints (and probably won't have any in the future) that would trigger on a CG level. So I'm now wondering if it is possible to disable CG completely for Clippy, like when running |
The following is just my own opinion...
I think the short answer is no; clippy-driver is designed purely for linting with Clippy, not for actually compiling. Perhaps clippy-driver could handle this kind of usage with more care, but that's another discussion. The current guidance is "just use rustc to compile". So I think the readme section on clippy-driver should communicate the above more clearly. Instead of saying "rustc replacement" and "replace your rustc compilation commands...", it should say to use clippy-driver to lint with Clippy and continue to use rustc to compile. We can still mention something about output/codegen guarantees, but that's more of a footnote. |
Sounds good to me. Another alternative instead of silently disabling codegen is to error out if a contradicting option is requested, e.g. |
...although someone out there may be using it for quick development cycles with lints enabled. |
Currently, `clippy-driver` may run codegen, but this is an implementation detail. See rust-lang#8035. Signed-off-by: Miguel Ojeda <[email protected]>
Currently, `clippy-driver` may run codegen, but this is an implementation detail. See rust-lang#8035. Signed-off-by: Miguel Ojeda <[email protected]>
When invoking Clippy (via Cargo or
clippy-driver
), we get the usualrustc
outputs + the extra lints. However, is it guaranteed thatclippy-driver
will work as ifrustc
was called?That is, can we rely on the generated objects to be the same as the ones that
rustc
would have generated (modulo unrelated non-deterministic build issues) or they should always be built withoutclippy-driver
if they are intended for "production"?A potential use case would be to always use
clippy-driver
instead ofrustc
in a build system, thus always having Clippy lints enabled (as long as one is OK paying the performance penalty).(Followup to #6782.)
@rustbot label +C-question
The text was updated successfully, but these errors were encountered: