Skip to content

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

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

Activity

  1. arielb1 commented on Sep 14, 2017

    @arielb1
    Contributor

    cc @Manishearth that looks like your thing

  2. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    on Sep 14, 2017
  3. ollie27 commented on Sep 14, 2017

    @ollie27
    Contributor

    duplicate of #19140

  4. steveklabnik commented on Sep 14, 2017

    @steveklabnik
    Contributor

    Yup! Closing in favor of that.

  5. added a commit that references this issue on Jul 13, 2018
  6. added a commit that references this issue on Jul 31, 2018
  7. added a commit that references this issue on Aug 1, 2018
  8. added a commit that references this issue on Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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