-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
-Dwarnings cannot be overriden by later -W options, for both rustc and non-rustc lints #118140
Copy link
Copy link
Open
Labels
A-CLIArea: Command-line interface (CLI) to the compilerArea: Command-line interface (CLI) to the compilerA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-CLIArea: Command-line interface (CLI) to the compilerArea: Command-line interface (CLI) to the compilerA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Consider the following code:
I would expect
cargo rustc -- -Dwarnings -Wdead-codeto merely warn about the dead code (because the-Wcomes after the-Dand thus should "reset" the dead-code lint's level back to "warn"), but it actually ignores the-Woption and treats the dead code as an error:Contrast with
cargo rustc -- -Dunused -Wdead-code, which does treat the final lint level of dead-code as "warn" rather than "deny":-Dwarningseven has the same effect on non-rustc warnings, such as from clippy. For example, runningcargo clippy -- -Dwarnings -W clippy::styleon the code above causes theassert!(true)to be treated as an error rather than a warning; contrast withcargo clippy -- -D clippy::all -W clippy::style, which first denies everything in the style group (among others) and then sets the style group's lint level back to "warn", with an end result of theassert!(true)only producing a warning.In addition, as far as I understand it, the
[lints]table added toCargo.tomlin Rust 1.74 is implemented by converting the lint fields to command-line options for rustc, rustdoc, and clippy, and so anyone trying to deny all warn-by-default lints with some exceptions is up a creek.Meta
rustc --version --verbose:rustc +nightly --version --verbose: