Skip to content

Spurious rustdoc::broken_intra_doc_links reported by linking to macro defined later #98804

Closed
@unageek

Description

@unageek

I tried this code:

/// [`bar`]
#[macro_export]
macro_rules! foo {
    () => {};
}

/// [`foo`]
#[macro_export]
macro_rules! bar {
    () => {};
}

I expected to see this happen: No warning is reported by cargo doc.

Instead, this happened: The following warning is reported:

warning: unresolved link to `bar`
 --> src/issue.rs:1:7
  |
1 | /// [`bar`]
  |       ^^^ no item named `bar` in scope
  |
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
  = note: `macro_rules` named `bar` exists in this crate, but it is not in scope at this link's location

Despite the warning, the generated link does work as expected.

This does not happen if I change [`bar`] to [`crate::bar`].

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (46b8c23f3 2022-07-01)
binary: rustc
commit-hash: 46b8c23f3eb5e4d0e0aa27eb3f20d5b8fc3ed51f
commit-date: 2022-07-01
host: aarch64-apple-darwin
release: 1.64.0-nightly
LLVM version: 14.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc 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