Skip to content

weird behavior from -Fdead_code vs -Funused #126029

@andrewbanchich

Description

@andrewbanchich

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) 
  1. i thought since dead_code is a subset of the unused lint group that if -Fdead_code produced errors that -Funused should produce at least the same number of errors.
  2. why is that a warning? shouldn't warning: allow(unused_imports) incompatible with previous forbid be an error since i added a forbid?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.L-dead_codeLint: dead_codeL-unused_importsLint: unused_importsT-clippyRelevant to the Clippy team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions