24

What is the difference between

#[allow(dead_code)]
// ...some code

and

#[allow(unused)]
// ...some code
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
109149
  • 1,223
  • 1
  • 8
  • 24

1 Answers1

24

dead_code is one specific lint that is defined as:

declare_lint! {
    pub DEAD_CODE,
    Warn,
    "detect unused, unexported items"
}

unused is a lint group that is composed of dead_code and many other lints. It is defined as:

add_lint_group!(
    "unused",
    UNUSED_IMPORTS,
    UNUSED_VARIABLES,
    UNUSED_ASSIGNMENTS,
    DEAD_CODE,
    UNUSED_MUT,
    UNREACHABLE_CODE,
    UNREACHABLE_PATTERNS,
    OVERLAPPING_PATTERNS,
    UNUSED_MUST_USE,
    UNUSED_UNSAFE,
    PATH_STATEMENTS,
    UNUSED_ATTRIBUTES,
    UNUSED_MACROS,
    UNUSED_ALLOCATION,
    UNUSED_DOC_COMMENTS,
    UNUSED_EXTERN_CRATES,
    UNUSED_FEATURES,
    UNUSED_LABELS,
    UNUSED_PARENS,
    UNUSED_BRACES,
    REDUNDANT_SEMICOLONS
);
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
  • 5
    For those interested in terminology, ["items"](https://doc.rust-lang.org/reference/items.html) are almost anything that can be declared at the module level: structs, traits, enums, functions, statics, etc. – kmdreko Oct 27 '20 at 18:01