-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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 nameC-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.
Description
I tried this code:
/// [type@std::io::not::here]
pub fn f() {}
I expected to the same diagnostic as without a disambiguator:
warning: unresolved link to `std::io::not::here`
--> tmp.rs:2:6
|
2 | /// [std::io::not::here]
| ^^^^^^^^^^^^^^^^^^ the module `io` has no inner item named `not`
Instead, rustdoc gave a diagnostic that made no sense:
warning: unresolved link to `std::io::not::here`
--> tmp.rs:1:6
|
1 | /// [type@std::io::not::here]
| ^^^^^^^^^^^^^^^^^^^^^^^ the module `io` has no type named `std::io`
Meta
rustc --version --verbose
:
rustdoc 1.48.0-nightly (bbc677480 2020-09-18)
Relevant code:
rust/src/librustdoc/passes/collect_intra_doc_links.rs
Lines 209 to 230 in 8a13fc4
// `variant_field` looks at 3 different path segments in a row. | |
// But `NoAssocItem` assumes there are only 2. Check to see if there's | |
// an intermediate segment that resolves. | |
_ => { | |
let intermediate_path = format!("{}::{}", path, variant_name); | |
// NOTE: we have to be careful here, because we're already in `resolve`. | |
// We know this doesn't recurse forever because we use a shorter path each time. | |
// NOTE: this uses `TypeNS` because nothing else has a valid path segment after | |
let kind = if let Some(intermediate) = self.check_full_res( | |
TypeNS, | |
&intermediate_path, | |
module_id, | |
current_item, | |
extra_fragment, | |
) { | |
ResolutionFailure::NoAssocItem(intermediate, variant_field_name) | |
} else { | |
// Even with the shorter path, it didn't resolve, so say that. | |
ResolutionFailure::NoAssocItem(ty_res, variant_name) | |
}; | |
Err(kind.into()) | |
} |
The issue is that
variant_field
is only called for the value namespace, but it's in charge of giving diagnostics for intermediate paths. That logic should instead be moved to fn resolution_failure
.Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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 nameC-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.