Skip to content

Warning "variant is never used" is confusing when programmer just woke up #44565

Closed
@nox

Description

@nox

I was changing some code from integer constants to a proper enum and was greeted by the following warning:

   Compiling script v0.0.1 (file:///Users/nox/src/servo/components/script)
warning: variant is never used: `HaveMetadata`
  --> /Users/nox/src/servo/components/script/dom/htmlmediaelement.rs:88:5
   |
88 |     HaveMetadata = HTMLMediaElementConstants::HAVE_METADATA as u8,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

The warning sounded weird to me because I was pattern-matching on that damn variant in various places of the code; but I was pointed out to the fact that I wasn't actually creating that value.

Maybe the warning should be rewritten to explicitly mention value creation?

Cc @arielb1

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