Open
Description
When a doc comment refers to Self
inside an impl
block for a type that is not in scope, rustdoc
can't properly resolve Self
.
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:
struct Foo {
foo: i32,
}
mod bar {
impl crate::Foo {
/// Baz the [`Self::foo`].
pub fn baz(&self) {
println!("bazzing the foo");
}
}
}
This produces a broken link in the documentation and the following warning:
$ cargo doc
Documenting foo v0.1.0 (/tmp/2021-05-02-18-45-24/foo)
warning: unresolved link to `Foo::foo`
--> src/main.rs:7:16
|
7 | /// Baz the [`Self::foo`].
| ^^^^^^^^^^^ no item named `Foo` in scope
|
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.66s
Meta
I tested this using:
Both show the same problem.
@rustbot modify labels: +A-rustdoc
Metadata
Metadata
Assignees
Labels
Area: Intra-doc links, the ability to link to items in docs by nameCategory: This is a bug.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the rustdoc team, which will review and decide on the PR/issue.