-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #95337 - petrochenkov:doclink3, r=camelid
rustdoc: Fix resolution of `crate`-relative paths in doc links Resolve `crate::foo` paths transparently to rustdoc, so their resolution no longer affects diagnostics and modules used for determining traits in scope. The proper solution is to account for the current `module_id`/`parent_scope` in `fn resolve_crate_root`, but it's a slightly larger compiler changes. This PR moves the code closer to it, but keeps it rustdoc-specific. Fixes #78696 Fixes #94924
- Loading branch information
Showing
6 changed files
with
53 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#![deny(rustdoc::broken_intra_doc_links)] | ||
|
||
/// [crate::DoesNotExist] | ||
//~^ ERROR unresolved link to `crate::DoesNotExist` | ||
pub struct Item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: unresolved link to `crate::DoesNotExist` | ||
--> $DIR/crate-nonexistent.rs:3:6 | ||
| | ||
LL | /// [crate::DoesNotExist] | ||
| ^^^^^^^^^^^^^^^^^^^ no item named `DoesNotExist` in module `crate_nonexistent` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/crate-nonexistent.rs:1:9 | ||
| | ||
LL | #![deny(rustdoc::broken_intra_doc_links)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pub mod io { | ||
pub trait Read { | ||
fn read(&mut self); | ||
} | ||
} | ||
|
||
pub mod bufreader { | ||
// @has crate_relative_assoc/bufreader/index.html '//a/@href' 'struct.TcpStream.html#method.read' | ||
//! [`crate::TcpStream::read`] | ||
use crate::io::Read; | ||
} | ||
|
||
pub struct TcpStream; | ||
|
||
impl crate::io::Read for TcpStream { | ||
fn read(&mut self) {} | ||
} |