Skip to content

Clean up handling of WrongNamespace in collect_intra_doc_links #77150

Open

Description

Rustdoc looks in different namespaces for diagnostics: https://github.com/rust-lang/rust/blob/66a9cfadf89439ad3ea1b67b996c0a90ca4763bf/src/librustdoc/passes/collect_intra_doc_links.rs#L1569-L1572
So this is handled properly:

warning: unresolved link to `file::into_iter`
 --> tmp.rs:1:6
  |
1 | /// [type@file::into_iter]
  |      ^^^^^^^^^^^^^^^^^^^^ `file` is a macro, not a module or type, and cannot have associated items

However (after #76955), resolution_failure only looks at other namespaces if there are multiple path segments. So https://github.com/rust-lang/rust/blob/66a9cfadf89439ad3ea1b67b996c0a90ca4763bf/src/librustdoc/passes/collect_intra_doc_links.rs#L1114 and https://github.com/rust-lang/rust/blob/66a9cfadf89439ad3ea1b67b996c0a90ca4763bf/src/librustdoc/passes/collect_intra_doc_links.rs#L1242-L1244 are still necessary, because they handle cases like value@file and type@file.

It would be nice to clean this up so that WrongNamespace is only handled in one place, in resolution_failure.

Originally posted by @jyn514 in #76955 (comment)

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-diagnosticsArea: Messages for errors, warnings, and lintsA-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameC-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-lowLow priorityT-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