Skip to content

Rustdoc omits source line numbers in diagnostics if they originate in a macro #84694

Open
@jyn514

Description

@jyn514

I tried this code:

top_level_options!(
/// The top-level command-line options struct.
///
/// For each option, one has to specify how it behaves with regard to the
/// dependency tracking system of incremental compilation. This is done via the
/// square-bracketed directive after the field type. The options are:
///
/// [TRACKED]

I expected to see this happen: Rustdoc shows the line number of the broken link, like it does normally:

warning: unresolved link to `x`
 --> src/lib.rs:1:6
  |
1 | //! [x]
  |      ^ no item named `x` in scope
  |
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
  = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

Instead, this happened:

 Documenting rustc_session v0.0.0 (/checkout/compiler/rustc_session)
error: unresolved link to `TRACKED`
   --> compiler/rustc_session/src/options.rs:61:12
    |
61  |           $( #[$top_level_attr] )*
...
...
97  | / top_level_options!(
99  | |     ///
99  | |     ///
100 | |     /// For each option, one has to specify how it behaves with regard to the
201 | |     }
202 | | );
    | |__- in this macro invocation
    |
    |
    = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
    = note: the link appears in this line:
            
            [TRACKED]
             ^^^^^^^
    = note: no item named `TRACKED` in scope
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

Meta

rustc --version --verbose:

Originally posted by @rust-log-analyzer in #84233 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.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