Skip to content

unused_doc_comments warning reported for each doc comment line on macro invocation, unlike on other expressions #83768

Closed
@camelid

Description

@camelid

Other expressions work as expected: it reports just one error, for the whole sequence of doc comment lines.

macro_rules! foo { () => {}; }

fn main() {
    /// line1
    /// line2
    /// line3
    foo!();
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
warning: unused doc comment
 --> src/main.rs:4:5
  |
4 |     /// line1
  |     ^^^^^^^^^ rustdoc does not generate documentation for macro invocations
  |
  = note: `#[warn(unused_doc_comments)]` on by default
  = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion

warning: unused doc comment
 --> src/main.rs:5:5
  |
5 |     /// line2
  |     ^^^^^^^^^ rustdoc does not generate documentation for macro invocations
  |
  = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion

warning: unused doc comment
 --> src/main.rs:6:5
  |
6 |     /// line3
  |     ^^^^^^^^^ rustdoc does not generate documentation for macro invocations
  |
  = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion

warning: 3 warnings emitted

    Finished dev [unoptimized + debuginfo] target(s) in 1.65s
     Running `target/debug/playground`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.T-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