rustdoc: Fix invalid suggestions on ambiguous intra doc links#108699
rustdoc: Fix invalid suggestions on ambiguous intra doc links#108699GuillaumeGomez wants to merge 2 commits intorust-lang:masterfrom
Conversation
24483e9 to
1588d7d
Compare
1588d7d to
a830d71
Compare
|
This doesn't seem correct. Try running the below test case: // This is ensuring that the UI output for associated items works when it's being documented
// from another item.
#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
pub trait Trait {
type Trait;
const Trait: usize;
}
/// [`Trait`]
//~^ ERROR
/// [`Trait::Trait`]
//~^ ERROR
pub const Trait: usize = 0;Details |
notriddle
left a comment
There was a problem hiding this comment.
Add above test case to test suite, and fix buggy check for item kind.
a830d71 to
8247b93
Compare
|
I was relying too much on the item on which the intra-doc link was. Big mistake. So instead, I now directly look at the I also added your test, thanks for it! |
|
Still falls over, this time in a case that was constructed to not actually have duplicates (so scanning for duplicates does the wrong thing). #![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
pub trait Trait {
type Trait;
}
/// [`Struct::Trait`]
//~^ ERROR
pub struct Struct;
impl Trait for Struct {
type Trait = Struct;
}
impl Struct {
pub const Trait: usize = 0;
}error: `Struct::Trait` is and an associated constant |
8247b93 to
ff4352e
Compare
|
The problem was that I was stopping the "discovery" when I found one or more match in one location, preventing us to go through all of them. I removed this limitation, fixing this bug and added a new test. |
|
There's also a few corner cases involving primitives: #![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
/// [`u32::MAX`]
//~^ ERROR
pub mod u32 {
pub trait MAX {}
}Details#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
/// [`u32::MAX`]
//~^ ERROR
pub mod u32 {
pub use std::primitive::u32 as MAX;
}Details#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
pub trait Trait {
type MAX;
}
/// [`u32::MAX`]
//~^ ERROR
impl Trait for u32 {
type MAX = u32;
}Details#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
/// [`u32::MAX`]
//~^ ERROR
pub trait T {
type MAX;
}
impl T for u32 {
type MAX = ();
}Details |
|
Why is this rewriting so much of the resolution code? Don't we already do the majority of this work elsewhere in the pass? |
We could indeed store directly the information we get from the |
|
I'll close this one in favour of #109104. |
Fixes #108653.
r? @notriddle