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

Clean up handling of WrongNamespace in collect_intra_doc_links #77150

Open
jyn514 opened this issue Sep 24, 2020 · 3 comments
Open

Clean up handling of WrongNamespace in collect_intra_doc_links #77150

jyn514 opened this issue Sep 24, 2020 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-low Low priority T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Sep 24, 2020

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)

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. P-low Low priority A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Sep 24, 2020
@max-heller
Copy link
Contributor

max-heller commented Jan 4, 2021

Attempting to disambiguate associated types/values of primitives with an incompatible disambiguator gives a confusing error:

error: unresolved link to `str::trim`
   |
 3 | //! [struct@str::trim]
   |      ^^^^^^^^^^^^^^^^
   |      |
   |      this link resolves to the associated function `trim`, which is not in the type namespace
   |      help: to link to the associated function, add parentheses: `str::trim()`

The error stems from a ResolutionFailure::WrongNamespace.

Originally posted in #80660 (comment)

Edit: I'd expect an "incompatible link kind" error

@jyn514 jyn514 added the A-diagnostics Area: Messages for errors, warnings, and lints label Jan 4, 2021
@jyn514 jyn514 added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Nov 9, 2021
@jacobmealey
Copy link

@jyn514 I see this ticket is a couple of years old, are you still willing to mentor it / is the work still relevant?

@jyn514
Copy link
Member Author

jyn514 commented Sep 18, 2022

I'm willing to mentor, but I honestly don't know if it's still relevant. The first step would be to find where the code is today and see if it still has the original issue I posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-low Low priority 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

4 participants