rust icon indicating copy to clipboard operation
rust copied to clipboard

The lint `unused_doc_comments` classifies all kinds of `#[doc …]` attributes as documentation comments

Open fmease opened this issue 3 years ago • 2 comments

The lint unused_doc_comments triggers on any #[doc …] / #![doc …] (on any token stream inside the attribute) when it should only trigger on actual documentation comments i.e. #[doc = …] / #![doc = …].

E.g. the following code incorrectly labels #[doc(hidden)] as a doc comment:

fn f<#[doc(hidden)] T>() {}
warning: unused doc comment
 --> q.rs:1:6
  |
1 | fn f<#[doc(hidden)] T>() {}
  |      ^^^^^^^^^^^^^^ - rustdoc does not generate documentation for generic parameters
  |
  = note: `#[warn(unused_doc_comments)]` on by default
  = help: use `//` for a plain comment

@rustbot label A-lint @rustbot claim

fmease avatar Apr 13 '22 13:04 fmease

@fmease if you change this, I think you should also make sure that unused_attributes is being run for doc(hidden) attributes and not just built-in attrs.

jyn514 avatar Apr 13 '22 14:04 jyn514

Revisiting this, I'm inclined to emit unused_attributes for those kinds of doc attrs but I guess it's a bit weird to emit a rustdoc-specific lint in one situation and a rustdoc-agnostic one in another. I really don't want to intro a new rustdoc-specific lint for this. Impl is trivial but those kinds of decisions are always a bit annoying ^^'

fmease avatar Mar 23 '24 00:03 fmease