-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustdoc: Fix invalid suggestions on ambiguous intra doc links #108699
rustdoc: Fix invalid suggestions on ambiguous intra doc links #108699
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;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 {}
}
#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
/// [`u32::MAX`]
//~^ ERROR
pub mod u32 {
pub use std::primitive::u32 as MAX;
}
#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
pub trait Trait {
type MAX;
}
/// [`u32::MAX`]
//~^ ERROR
impl Trait for u32 {
type MAX = u32;
}
#![deny(rustdoc::broken_intra_doc_links)]
#![allow(nonstandard_style)]
/// [`u32::MAX`]
//~^ ERROR
pub trait T {
type MAX;
}
impl T for u32 {
type MAX = ();
}
|
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