-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Make --force-warns
a normal lint level option
#86970
Conversation
r? @varkor (rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! We should add some tests. Specifically:
- --force-warns works with a bogus lint name
- --force-warns and -F are not overwritten by later lint options
This comment has been minimized.
This comment has been minimized.
I think I've made all the requested changes. Let me know if I missed anything! |
r? @rylev |
Unfortunately, I don't have review rights. I'll do a review though, but someone else will have to invoke bors. r? @davidtwco |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! The issue with the E0602 being emitted multiple times is strange, but I don't think it's a blocker.
| | ||
= note: requested on the command line with `--force-warns foo_qux` | ||
|
||
error[E0602]: unknown lint: `foo_qux` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why this error gets emitted multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens for some other cases as well. I think it's a product of the way the tests are run, though I'm not totally sure?
let lint_flag_val = Symbol::intern(lint_name); | ||
|
||
let ids = match store.find_lints(&lint_name) { | ||
Ok(ids) => ids, | ||
Err(_) => continue, // errors handled in check_lint_name_cmdline above | ||
}; | ||
for id in ids { | ||
// ForceWarn and Forbid cannot be overriden | ||
if let Some((Level::ForceWarn | Level::Forbid, _)) = specs.get(&id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this behavior documented anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort of. However, the fact that forbid currently overrides the others isn't specified, and force-warns
isn't documented at all because it's unstable. Given that the behavior is intrinsic to the definition of these lint levels, I don't think it's too surprising. It might be worth documenting it in the long run though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too, I'd like to see @rylev's comments resolved but I don't think those comments ought to block this landing.
@bors r+ |
📌 Commit dbdce6e has been approved by |
…vidtwco Make `--force-warns` a normal lint level option Now that `ForceWarn` is a lint level, there's no reason `--force-warns` should be treated differently from other options that set lint levels. This merges the `ForceWarn` handling in with the other lint level command line options. It also unifies all of the relevant selection logic in `compiler/rustc_lint/src/levels.rs`, rather than having some of it weirdly elsewhere. Fixes rust-lang#86958, which arose from the special-cased handling of `ForceWarn` having had an error in it.
…vidtwco Make `--force-warns` a normal lint level option Now that `ForceWarn` is a lint level, there's no reason `--force-warns` should be treated differently from other options that set lint levels. This merges the `ForceWarn` handling in with the other lint level command line options. It also unifies all of the relevant selection logic in `compiler/rustc_lint/src/levels.rs`, rather than having some of it weirdly elsewhere. Fixes rust-lang#86958, which arose from the special-cased handling of `ForceWarn` having had an error in it.
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
☔ The latest upstream changes (presumably #87182) made this pull request unmergeable. Please resolve the merge conflicts. |
dbdce6e
to
10cb380
Compare
Rebased! |
@bors r+ |
📌 Commit 10cb380 has been approved by |
@bors delegate=rylev |
✌️ @rylev can now approve this pull request |
☀️ Test successful - checks-actions |
Now that
ForceWarn
is a lint level, there's no reason--force-warns
should be treated differently from other options that set lint levels. This merges theForceWarn
handling in with the other lint level command line options. It also unifies all of the relevant selection logic incompiler/rustc_lint/src/levels.rs
, rather than having some of it weirdly elsewhere.Fixes #86958, which arose from the special-cased handling of
ForceWarn
having had an error in it.