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

rustc_session: forbid lints override regardless of position #70918

Merged
merged 1 commit into from
Apr 9, 2020

Conversation

tobithiel
Copy link
Contributor

@tobithiel tobithiel commented Apr 8, 2020

Addresses the regression reported in #70819 for command line arguments, but does not address the source code flag regression.

@rust-highfive
Copy link
Collaborator

r? @davidtwco

(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 Apr 8, 2020
@davidtwco
Copy link
Member

r=me if you're happy with this (and unmark as a draft)

@tobithiel tobithiel marked this pull request as ready for review April 8, 2020 15:31
@tobithiel
Copy link
Contributor Author

tobithiel commented Apr 8, 2020

r=@davidtwco

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 8, 2020

📌 Commit f03db79 has been approved by davidtwco

@bors
Copy link
Contributor

bors commented Apr 8, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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 Apr 8, 2020
@RalfJung
Copy link
Member

RalfJung commented Apr 9, 2020

TBH I think this is the wrong way to fix the problem. Given that the issue affects both in-code and CLI argument lint levels, I suspect that whatever fixes the former will also fix the latter. This PR adds a temporary hack that most likely can be removed again once in-code lint levels work as expected.

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 9, 2020
Rollup of 7 pull requests

Successful merges:

 - rust-lang#67705 (Use unrolled loop for searching NULL in [u16] on Windows)
 - rust-lang#70367 (save/restore `pessimistic_yield` when entering bodies)
 - rust-lang#70822 (Don't lint for self-recursion when the function can diverge)
 - rust-lang#70868 (rustc_codegen_ssa: Refactor construction of linker arguments)
 - rust-lang#70896 (Implement Chain with Option fuses)
 - rust-lang#70916 (Support `#[track_caller]` on functions in `extern "Rust" { ... }`)
 - rust-lang#70918 (rustc_session: forbid lints override regardless of position)

Failed merges:

r? @ghost
@bors bors merged commit 09052a6 into rust-lang:master Apr 9, 2020
for (passed_arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
let arg_pos = if let lint::Forbid = level {
// forbid is always specified last, so it can't be overridden
usize::max_value()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, this could be usize::MAX now. :)

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 9, 2020
…ochenkov

rustc_session CLI lint parsing: mark a temporary hack as such

This code was added in rust-lang#70918, but it should not be necessary any more once `forbid` works as expected for in-code attributes.

Cc @tobithiel @davidtwco
Centril added a commit to Centril/rust that referenced this pull request Apr 10, 2020
…ochenkov

rustc_session CLI lint parsing: mark a temporary hack as such

This code was added in rust-lang#70918, but it should not be necessary any more once `forbid` works as expected for in-code attributes.

Cc @tobithiel @davidtwco
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Nov 14, 2020
Previously, cap-lints was ignored when checking the previous forbid level, which
meant that it was a hard error to do so. This is different from the normal
behavior of lints, which are silenced by cap-lints; if the forbid would not take
effect regardless, there is not much point in complaining about the fact that we
are reducing its level.

It might be considered a bug that even `--cap-lints deny` would suffice to
silence the error on overriding forbid, depending on if one cares about failing
the build or precisely forbid being set. But setting cap-lints to deny is quite
odd and not really done in practice, so we don't try to handle it specially.

This also unifies the code paths for nested and same-level scopes. However, the
special case for CLI lint flags is left in place (introduced by rust-lang#70918) to fix
the regression noted in rust-lang#70819. That means that CLI flags do not lint on forbid
being overridden by a non-forbid level. It is unclear whether this is a bug or a
desirable feature, but it is certainly inconsistent. CLI flags are a
sufficiently different "type" of place though that this is deemed out of scope
for this commit.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 2, 2020
…kfelix

Use true previous lint level when detecting overriden forbids

Previously, cap-lints was ignored when checking the previous forbid level, which
meant that it was a hard error to do so. This is different from the normal
behavior of lints, which are silenced by cap-lints; if the forbid would not take
effect regardless, there is not much point in complaining about the fact that we
are reducing its level.

It might be considered a bug that even `--cap-lints deny` would suffice to
silence the error on overriding forbid, depending on if one cares about failing
the build or precisely forbid being set. But setting cap-lints to deny is quite
odd and not really done in practice, so we don't try to handle it specially.

This also unifies the code paths for nested and same-level scopes. However, the
special case for CLI lint flags is left in place (introduced by rust-lang#70918) to fix
the regression noted in rust-lang#70819. That means that CLI flags do not lint on forbid
being overridden by a non-forbid level. It is unclear whether this is a bug or a
desirable feature, but it is certainly inconsistent. CLI flags are a
sufficiently different "type" of place though that this is deemed out of scope
for this commit.

r? `@pnkfelix` perhaps?

cc rust-lang#77713 -- not marking as "Fixes" because of the lack of proper unused attribute handling in this PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants