Skip to content

rustdoc::broken_intra_doc_links behavior change with macro_rules not in scope since 1.63 #106142

Closed

Description

rustdoc >= 1.63 complains about this intra-doc link:

pub mod a {
    /// [`m`]
    pub fn f() {}

    #[macro_export]
    macro_rules! m {
        () => {};
    }
}

with:

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

warning: 1 warning emitted

However, the link is still generated in the rendered output, and points to the right place. Thus the text "unresolved link" is a bit confusing, especially since in earlier versions (<= 1.62), there was no warning for this case (and the link still got generated too).

With e.g. crate::m, the warning goes away.

Therefore, if the intended behavior is that the user writes something like crate::m, then when the user just wrote m the link should not be generated (which would make the text of the lint consistent) or the link could be generated but then the warning should say the link may still be generated.

On the other hand, if the intended behavior is that m still works as-is like in previous versions, then it is a false positive and a regression on the lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant 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