Skip to content

Commit

Permalink
rustdoc: Link to the docs on namespaces when an unknown disambiguator…
Browse files Browse the repository at this point in the history
… is found
  • Loading branch information
jyn514 committed Apr 7, 2021
1 parent 1c158b6 commit 9866ea0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/librustdoc/passes/collect_intra_doc_links.rs
Expand Up @@ -1924,7 +1924,20 @@ fn disambiguator_error(
msg: &str,
) {
diag_info.link_range = disambiguator_range;
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |_diag, _sp| {});
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp| {
let channel = match env!("CFG_RELEASE_CHANNEL") {
"stable" => env!("CFG_RELEASE_NUM"),
"beta" => "beta",
"nightly" | "dev" => "nightly",
// custom build of rustdoc maybe? link to the stable docs just in case
_ => "",
};
let msg = format!(
"see https://doc.rust-lang.org/{}/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators",
channel,
);
diag.note(&msg);
});
}

/// Report an ambiguity error, where there were multiple possible resolutions.
Expand Down
Expand Up @@ -10,6 +10,7 @@ note: the lint level is defined here
LL | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]`
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators

error: aborting due to previous error

11 changes: 11 additions & 0 deletions src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr
Expand Up @@ -10,36 +10,47 @@ note: the lint level is defined here
LL | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]`
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators

error: unknown disambiguator `bar`
--> $DIR/unknown-disambiguator.rs:3:35
|
LL | //! Linking to [foo@banana] and [`bar@banana!()`].
| ^^^
|
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators

error: unknown disambiguator `foo`
--> $DIR/unknown-disambiguator.rs:9:34
|
LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello].
| ^^^
|
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators

error: unknown disambiguator `foo`
--> $DIR/unknown-disambiguator.rs:9:48
|
LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello].
| ^^^
|
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators

error: unknown disambiguator ``
--> $DIR/unknown-disambiguator.rs:6:31
|
LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()).
| ^
|
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators

error: unknown disambiguator ``
--> $DIR/unknown-disambiguator.rs:6:57
|
LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()).
| ^
|
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators

error: aborting due to 6 previous errors

0 comments on commit 9866ea0

Please sign in to comment.