Skip to content

Misleading "unused" warning message #27559

Closed
@GuillaumeGomez

Description

@GuillaumeGomez

We got the following warning message:

warning: variant is never used: `Foo`, #[warn(dead_code)] on by default

For this code:

enum Something {
    Foo,
    NotFoo
}

fn main() {
    match Something::NotFoo {
        Something::Foo => {}
        _ => {}
    }
}

This warning could mislead users because for them, the Foo variant is used. Adding a specific warning message could be nice.

@eddyb proposed this message instead in this case:

"this variant is never instantiated"

cc @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions