简体   繁体   中英

What is the difference between the dead_code and unused lints?

What is the difference between

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

and

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

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
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM