Skip to content
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

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

Open
fmease opened this issue Apr 13, 2022 · 2 comments
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-unused_doc_comments Lint: unused_doc_comments P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Apr 13, 2022

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 fmease added the C-bug Category: This is a bug. label Apr 13, 2022
@rustbot rustbot added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Apr 13, 2022
@jyn514
Copy link
Member

jyn514 commented Apr 13, 2022

@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.

@fmease fmease added A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 1, 2023
@fmease fmease added the P-low Low priority label Mar 22, 2024
@fmease
Copy link
Member Author

fmease commented Mar 23, 2024

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 ^^'

@jieyouxu jieyouxu added the L-unused_doc_comments Lint: unused_doc_comments label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-unused_doc_comments Lint: unused_doc_comments P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants