Closed
Description
I tried this code:
#![allow(unused_imports, dead_code)]
// Uncomment this and the warning will go away
// use crate::io::Read;
pub mod io {
pub trait Read {
fn read(&mut self, buf: &mut [u8]) -> usize;
}
}
pub mod bufreader {
use crate::io::Read;
/// It can be excessively inefficient to work directly with a [`Read`] instance.
/// For example, every [`Read::read`] call to [`TcpStream::read`] or [`TcpStream::yes`] on [`TcpStream`]
///
/// [`TcpStream::yes`]: crate::net::TcpStream::yes
/// [`TcpStream::read`]: crate::net::TcpStream::read
/// [`Read::read`]: Read::read
/// [`TcpStream`]: crate::net::TcpStream
pub struct BufReader;
}
pub mod net {
pub struct TcpStream;
impl TcpStream {
fn yes() -> bool {
true
}
}
impl crate::io::Read for TcpStream {
fn read(&mut self, buf: &mut [u8]) -> usize {
buf.len()
}
}
}
I expected to see this happen: Rustdoc should complete with no warnings
Instead, this happened:
Only the following warning is output by rustdoc
warning: unresolved link to `self::net::TcpStream::read`
--> src/main.rs:13:30
|
13 | /// [`TcpStream::read`]: crate::net::TcpStream::read
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `TcpStream` has no field or associated item named `read`
|
= note: `#[warn(broken_intra_doc_links)]` on by default
If you uncomment the line as it says, the warning goes away.
Meta
rustc +stage2 --version --verbose
:
rustc 1.49.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.49.0-dev
Commit hash: b202532
Here's a crate that repros this issue: https://github.com/pitaj/rustdoc-78006-repro
@rustbot modify labels: T-doc, A-intra-doc-links
@jyn514 Here's the repro I promised.
First came across this in #78006
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.