Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kpreid opened this issue May 20, 2022 · 2 comments · Fixed by #97208
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kpreid
Copy link
Contributor

kpreid commented May 20, 2022

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

@kpreid kpreid added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 20, 2022
@fmease
Copy link
Member

fmease commented May 20, 2022

Sorry, stupid oversight that could've been prevented with a more extensive test. PR is up.

@TethysSvensson
Copy link
Contributor

This bug seems to affect the current beta release. Has the fix been backported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants