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:
|
// `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.
I tried this code:
I expected to the same diagnostic as without a disambiguator:
Instead, rustdoc gave a diagnostic that made no sense:
Meta
rustc --version --verbose:Relevant code:
rust/src/librustdoc/passes/collect_intra_doc_links.rs
Lines 209 to 230 in 8a13fc4
The issue is that
variant_fieldis only called for the value namespace, but it's in charge of giving diagnostics for intermediate paths. That logic should instead be moved tofn resolution_failure.