Skip to content
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

Merged
merged 2 commits into from
Jul 19, 2021

Conversation

inquisitivecrystal
Copy link
Contributor

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 #86958, which arose from the special-cased handling of ForceWarn having had an error in it.

@rust-highfive
Copy link
Collaborator

r? @varkor

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 8, 2021
Copy link
Member

@rylev rylev left a 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

@rust-log-analyzer

This comment has been minimized.

@rylev
Copy link
Member

rylev commented Jul 8, 2021

Now that force-warns is processed with other lints, you'll need to make sure that --cap-lints doesn't cap force-warns. This is somewhat duplicate logic found here.

Also, this PR should partially fix #70819 (the command line part of it) and thus it partially supersedes #85298.

@inquisitivecrystal
Copy link
Contributor Author

I think I've made all the requested changes. Let me know if I missed anything!

@varkor
Copy link
Member

varkor commented Jul 11, 2021

r? @rylev

@rust-highfive rust-highfive assigned rylev and unassigned varkor Jul 11, 2021
@rylev
Copy link
Member

rylev commented Jul 12, 2021

Unfortunately, I don't have review rights. I'll do a review though, but someone else will have to invoke bors.

r? @davidtwco

@rust-highfive rust-highfive assigned davidtwco and unassigned rylev Jul 12, 2021
Copy link
Member

@rylev rylev left a 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`
Copy link
Member

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?

Copy link
Contributor Author

@inquisitivecrystal inquisitivecrystal Jul 15, 2021

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) {
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

@davidtwco davidtwco left a 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.

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 15, 2021

📌 Commit dbdce6e has been approved by davidtwco

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 15, 2021
…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.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 15, 2021
…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.
@bors
Copy link
Contributor

bors commented Jul 16, 2021

🔒 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 self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout force-warn (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self force-warn --force-with-lease (update this PR)

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 git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging compiler/rustc_session/src/options.rs
CONFLICT (content): Merge conflict in compiler/rustc_session/src/options.rs
Auto-merging compiler/rustc_session/src/config.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 16, 2021
@bors
Copy link
Contributor

bors commented Jul 16, 2021

☔ The latest upstream changes (presumably #87182) made this pull request unmergeable. Please resolve the merge conflicts.

@inquisitivecrystal
Copy link
Contributor Author

Rebased!

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 19, 2021

📌 Commit 10cb380 has been approved by davidtwco

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 19, 2021
@davidtwco
Copy link
Member

@bors delegate=rylev

@bors
Copy link
Contributor

bors commented Jul 19, 2021

✌️ @rylev can now approve this pull request

@bors
Copy link
Contributor

bors commented Jul 19, 2021

⌛ Testing commit 10cb380 with merge b543e0d...

@bors
Copy link
Contributor

bors commented Jul 19, 2021

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing b543e0d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 19, 2021
@bors bors merged commit b543e0d into rust-lang:master Jul 19, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

force-warns panics with unknown lint name
8 participants