Skip to content

error when a command line flag lowers a -F forbid - #165669

Open
Albab-Hasan wants to merge 2 commits into
rust-lang:mainfrom
Albab-Hasan:cli-forbid-lowering-error
Open

Albab-Hasan wants to merge 2 commits into
rust-lang:mainfrom
Albab-Hasan:cli-forbid-lowering-error

Conversation

@Albab-Hasan

@Albab-Hasan Albab-Hasan commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

-F x -A x on the command line silently kept the forbid while the crate attribute form is E0453. now both error. groups hard error too instead of the forbidden_lint_groups fcw since the cli never let them lower a forbid.

the skip started as the #70918 hack for #70819 and #86970 moved it into add_command_line. related #133346 #81670

cc @jyn514

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 9, 2026
@rustbot

rustbot commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Error: Failed to set assignee to jyn514: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

@jyn514

jyn514 commented Nov 9, 2026

Copy link
Copy Markdown
Member

r? compiler

@jyn514

jyn514 commented Nov 9, 2026

Copy link
Copy Markdown
Member

cc @folkertdev

@folkertdev folkertdev left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code change looks fine but I'm unsure on the implications. This is, in a way, a breaking change, right?

r? JonathanBrouwer for a second opinion

View changes since this review

@jyn514

jyn514 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

yes, this is a breaking change. the motivation here is that we want to desugar -A flags to #![allow(...)] for the --crate-attr RFC.

@JonathanBrouwer JonathanBrouwer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm but would be nice if we could improve this diagnostic.
This definitely needs some kind of compiler sign-off though, probably a FCP.
I'll ask in internal zulip chats what we want here, I'll get back to you

View changes since this review

a later `-A`, `-W` or `--force-warn` for a lint forbidden by an earlier `-F` was silently ignored while the same order as crate attributes is E0453. command line levels now go through `insert_spec` like attributes so `-F dead_code -A dead_code` is E0453 too. lint groups also hard error instead of the `forbidden_lint_groups` future compat warning since the command line never let them lower a forbid.
the E0453 for a command line flag has no span so it only said where the `forbid` came from. it now also names the flag that tried to lower it.
@Albab-Hasan
Albab-Hasan force-pushed the cli-forbid-lowering-error branch from 95dff70 to 615f932 Compare November 13, 2026 19:07
@rustbot

rustbot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Albab-Hasan

Copy link
Copy Markdown
Contributor Author

added the note so it now says allow lint level was set on command line (-A unused) above the forbid one. if this ends up needing an fcp i can write the summary for it if that helps :)

@jieyouxu jieyouxu added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. A-CLI Area: Command-line interface (CLI) to the compiler A-lint-levels Area: lint levels labels Nov 14, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

This PR changes the behaviour of passing -F lint -A lint, -F lint_group -A lint, and -F lint_group -A lint_group.

  • Currently the -A is silently ignored, after this PR this produces an error:

    $ rustc -F unused_variables -A unused_variables ./src/main.rs
    error[E0453]: allow(unused) incompatible with previous forbid
       |
       = note: `allow` lint level was set on command line (`-A unused_variables`)
       = note: `forbid` lint level was set on command line (`-F unused_variables`)
    
  • This matches the behaviour of -F lint with a crate-level #![allow(lint)], which is also an error.

    #![allow(unused_variables)]
    $ rustc -F unused_variables ./src/main.rs
    error[E0453]: allow(unused_variables) incompatible with previous forbid
    --> ./src/main.rs:1:10
    |
    1 | #![allow(unused_variables)]
    |          ^^^^^^^^^^^^^^^^ overruled by previous forbid
    |
    = note: `forbid` lint level was set on command line (`-F unused_variables`)
    
  • This does not match the behaviour of -F lint_group with a crate-level #![allow(lint)] or #![allow(lint_group)], which are both a FCW.

    #![allow(unused_variables)]
    $ rustc -F unused ./src/main.rs
    warning: allow(unused_variables) incompatible with previous forbid
     --> ./src/main.rs:1:10
      |
    1 | #![allow(unused_variables)]
      |          ^^^^^^^^^^^^^^^^ overruled by previous forbid
      |
      = note: `forbid` lint level was set on command line (`-F unused`)
      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
      = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
      = note: `#[warn(forbidden_lint_groups)]` (part of `#[warn(future_incompatible)]`) on by default
    
  • This does not match the behaviour of #![forbid(lint_group)] with a crate-level #![allow(lint)] or #![allow(lint_group)], which are both a FCW.

    #![forbid(unused)]
    #![allow(unused_variables)]
    $ rustc ./src/main.rs
    
    warning: allow(unused_variables) incompatible with previous forbid
     --> ./src/main.rs:2:10
      |
    1 | #![forbid(unused)]
      |           ------ `forbid` level set here
    2 | #![allow(unused_variables)]
      |          ^^^^^^^^^^^^^^^^ overruled by previous forbid
      |
      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
      = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
      = note: `#[warn(forbidden_lint_groups)]` (part of `#[warn(future_incompatible)]`) on by default
    
    warning: 1 warning emitted
    

@rfcbot fcp merge compiler

@rust-rfcbot

rust-rfcbot commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

@JonathanBrouwer has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. and removed needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Nov 16, 2026
@JonathanBrouwer JonathanBrouwer added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 17, 2026
@jieyouxu jieyouxu self-assigned this Nov 19, 2026
@RalfJung

RalfJung commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Some relevant past PRs that led us to where we are today:

I don't know if this new PR is undoing past changes or continuing in the same spirit, but it'd be good if someone could check that. :)

EDIT: I see the first of them is mentioned in the PR description, so I assume it's all consistent. 🎉

@jieyouxu jieyouxu removed their assignment Nov 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: Command-line interface (CLI) to the compiler A-lint-levels Area: lint levels disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants