weird behavior from `-Fdead_code` vs `-Funused`
Open
Nobody has claimed this yet.
A-lints
C-bug
L-dead_code
L-unused_imports
T-clippy
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
running cargo clippy -- -Dwarnings -Fdead_code in my binary produces two errors and no warnings. both errors are coming from clap.
error[E0453]: allow(dead_code) incompatible with previous forbid
|
| #[derive(Parser, Debug, Clone)]
| ^^^^^^ overruled by previous forbid
|
= note: `forbid` lint level was set on command line
= note: this error originates in the derive macro `Parser` (in Nightly builds, run with -Z macro-backtrace for more info)
however, running cargo clippy -- -Dwarnings -Funused produces 1158 warnings and no errors. and example of one of the warnings is
warning: allow(unused_imports) incompatible with previous forbid
|
| info!("a log message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: `forbid` lint level was set on command line
= note: this warning originates in the macro `$crate::valueset` which comes from the expansion of the macro `info` (in Nightly builds, run with -Z macro-backtrace for more info)
- i thought since
dead_codeis a subset of theunusedlint group that if-Fdead_codeproduced errors that-Funusedshould produce at least the same number of errors. - why is that a warning? shouldn't
warning: allow(unused_imports) incompatible with previous forbidbe an error since i added a forbid?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two commands, cargo clippy -- -Dwarnings -Fdead_code and cargo clippy -- -Dwarnings -Funused, using the reported clap and logging macro cases. Trace how lint groups expand and how incompatible allow attributes are diagnosed; done means explaining why the results differ and why one diagnostic remains a warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100