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

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

Closed
unageek opened this issue Jul 2, 2022 · 2 comments
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@unageek
Copy link

unageek commented Jul 2, 2022

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
@unageek unageek added the C-bug Category: This is a bug. label Jul 2, 2022
@petrochenkov
Copy link
Contributor

I suspect that the code you posted is not in the root module, right?
In that case bar is indeed not in scope at the location of the [`bar`] link, it's an intentional change made in #96676.

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

This is a compatibility measure to keep stuff on docs.rs working if possible.

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 2, 2022
@unageek
Copy link
Author

unageek commented Jul 2, 2022

In that case bar is indeed not in scope at the location of the [`bar`] link

Aha! You are right! Thank you for your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants