-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Diagnostics for -D
flags make it slightly harder to allow vs. #![deny(...)]
#114030
Comments
Is there a reason why the non rust/compiler/rustc_middle/src/lint.rs Lines 216 to 231 in fd56162
|
I think that error message can be improved also, to error with a better error message and ideally a suggestion, especially if there is an actual lint with that name.
Yeah, maybe that wording is too encouraging in that direction. Lints are there to point out potentially bad code, and sometimes you might want to Personally I think the best way to address this issue is to provide the ability to pass a span for these lints, in a way that it can both be passed by linux's makefile, as well as by Cargo via |
Also yeah I think the best is to pass the original spelling in the diagnostic, so that you can easily grep for it in your makefile, but if the lint name is mentioned anywhere, it should use |
Ah, I think I see what you mean (thanks for the links and the context!). When I opened the issue, I had in mind the "permanent/non-prototyping" case, i.e. when one needs to commit the In the kernel, for the "prototyping/local development" case, one may So a kernel developer is not expected to have to tweak (Tweaking the |
The span would be chosen entirely by the person calling the compiler, so it's your choice to point it to the makefile, or some kbuild option file. But if latter is chosen, IIRC only non-default config options are stored so if the default is to warn, then there is only the makefile to point to.
Yeah for features it's easy to suggest something good because they are always per-crate, you can't enable features on a more fine or roughly grained basis (outside of |
…rochenkov Add an allow attribute suggestion along with the implied by suggestion This PR adds an `#[allow(...)]` attribute hep suggestion along with the implied by suggestion: ```diff note: `-W dead-code` implied by `-W unused` + help: to override `-W unused` add `#[allow(dead_code)]` ``` This PR also adds the `OnceHelp` lint level (similar to `OnceNote`) to only put the help message one time, like the implied note. Related to rust-lang#114030
…chenkov Add an allow attribute suggestion along with the implied by suggestion This PR adds an `#[allow(...)]` attribute hep suggestion along with the implied by suggestion: ```diff note: `-W dead-code` implied by `-W unused` + help: to override `-W unused` add `#[allow(dead_code)]` ``` This PR also adds the `OnceHelp` lint level (similar to `OnceNote`) to only put the help message one time, like the implied note. Related to rust-lang#114030
I'm fine with closing. Spans are cool technology but I think #114089 has fixed most of the issues. |
Sounds good, thanks! Let's see what @Urgau says, perhaps there was a reason for the "Related" tag instead of "Fixes" in the PR. |
This can be closed. I didn't do it in the PR since it was wasn't clear if my PR was all that would be needed to fix it. |
Thanks! Closing then :) |
When using
-D
command-line flags to deny some lints, the compiler emits diagnostics that are slightly harder to allow, compared to a denied lint via#![deny(...)]
.Compare the following cases:
The first two provide, one way or another, the name of the lint that can be easily copy-pasted from the terminal to
allow(...)
it. In particular, they provide the name of the lint with underscores:However, in the latter two cases, we get a message that is useful, but one needs to manually replace the minuses with underscores (and there may be a few in other cases):
(By the way, note that the diagnostics also seem to print minus signs even if one used underscores in the command line, like here, i.e.
-Ddead_code
-- see rust-lang/rust-clippy#11332 as well).For newcomers, it may make it harder to understand that one can
allow(...)
things locally with an attribute, plus it may not be obvious that they need to replace the minus signs, even if they tried:And, for experienced developers, it is anyway a bit annoying to have to do the replacement all the time.
I don't know what is the best way to improve this. Perhaps an extra
help:
line would not hurt, and in principle, it could be given in all cases:This follows the pattern for the suggestion when using unstable features:
Of course, this could potentially encourage users to
allow
things they should not.The text was updated successfully, but these errors were encountered: