Skip to content

Unexpected "deprecated" warning when derive attribute for enum and enum has deprecated items #38832

Closed
@Mingun

Description

@Mingun

Let's consider the following situation: there is a enumeration in which have an deprecated element. This enumeration derives implementation of some traits. In such case rustc generates deprecation warning, but actually deprecated item never used.

As in this case there is no control over the generated code, I consider that the warning shouldn't be. It is impossible to suppress warning also because the element is marked deprecated for the reason that he shouldn't be used obviously. If to suppress him, then meaning to mark a enumaration element as deprecated is lost.

Example of problem:

#![allow(dead_code)]
#[derive(Debug)]
enum Example {
    Var1,
    #[deprecated]
    Var2,
}
fn main() {
}

Output:

rustc 1.14.0 (e8a012324 2016-12-16)
warning: use of deprecated item, #[warn(deprecated)] on by default
 --> <anon>:6:5
  |
6 |     Var2,
  |     ^^^^

play-pen

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions