-
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 fails to properly resolve Self
in a submodule when the type is not in scope
#84827
Comments
Also related: if you do import a type with the same name, then rustdoc will think that is That can be demonstrated with this example: pub struct Foo {
pub foo: i32,
}
pub mod bar {
use crate::other::Foo;
impl crate::Foo {
/// Baz the [`Self::foo`].
pub fn baz(&self) {
println!("bazzing the foo");
}
}
}
pub mod other {
pub struct Foo;
} Which produces the following warning:
And if I add a field with the same name, it really links to the wrong |
This is basically the issue from #83761 (comment), rustdoc should use the DefId instead of strings. |
Relevant code in case someone wants to take a look: rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 837 to 838 in e10cbc3
|
Basically the way to do this is to only do the string munging in rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 490 to 518 in e10cbc3
self_id.is_none() ; otherwise use self_id in the place of ty_res .
|
Ditto for rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 490 to 518 in e10cbc3
|
@rustbot claim |
When a doc comment refers to
Self
inside animpl
block for a type that is not in scope,rustdoc
can't properly resolveSelf
.It does resolve
Self
to a more specific name (Foo
in the example below), but then it can't find that name.A minimum example:
This produces a broken link in the documentation and the following warning:
Meta
I tested this using:
Both show the same problem.
@rustbot modify labels: +A-rustdoc
The text was updated successfully, but these errors were encountered: