Skip to content

False positive unused_attributes lint on doc(hidden) attribute on non-trait associated item #97205

Closed
@kpreid

Description

@kpreid

Given the following code:

pub struct Foo {}

impl Foo {
    #[doc(hidden)]
    pub const FOO: i32 = 0;
}

The current output (on nightly) is:

warning: `#[doc(hidden)]` is ignored on trait impl items
 --> src/lib.rs:4:5
  |
4 |     #[doc(hidden)]
  |     ^^^^^^^^^^^^^^ help: remove this attribute
  |
  = note: `#[warn(unused_attributes)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item

This warning is incorrect because this is not a trait impl, but an inherent impl.

Tested with local nightly rustc 1.63.0-nightly (cd282d7f7 2022-05-18) and Playground 2022-05-19 c0672870491e84362f76.

CC #96008 and @fmease

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions