Skip to content

Commit 9866ea0

Browse files
committed
rustdoc: Link to the docs on namespaces when an unknown disambiguator is found
1 parent 1c158b6 commit 9866ea0

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Diff for: src/librustdoc/passes/collect_intra_doc_links.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,20 @@ fn disambiguator_error(
19241924
msg: &str,
19251925
) {
19261926
diag_info.link_range = disambiguator_range;
1927-
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |_diag, _sp| {});
1927+
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp| {
1928+
let channel = match env!("CFG_RELEASE_CHANNEL") {
1929+
"stable" => env!("CFG_RELEASE_NUM"),
1930+
"beta" => "beta",
1931+
"nightly" | "dev" => "nightly",
1932+
// custom build of rustdoc maybe? link to the stable docs just in case
1933+
_ => "",
1934+
};
1935+
let msg = format!(
1936+
"see https://doc.rust-lang.org/{}/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators",
1937+
channel,
1938+
);
1939+
diag.note(&msg);
1940+
});
19281941
}
19291942

19301943
/// Report an ambiguity error, where there were multiple possible resolutions.

Diff for: src/test/rustdoc-ui/intra-doc/email-address-localhost.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ note: the lint level is defined here
1010
LL | #![deny(warnings)]
1111
| ^^^^^^^^
1212
= note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]`
13+
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
1314

1415
error: aborting due to previous error
1516

Diff for: src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,47 @@ note: the lint level is defined here
1010
LL | #![deny(warnings)]
1111
| ^^^^^^^^
1212
= note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]`
13+
= note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
1314

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

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

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

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

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

4455
error: aborting due to 6 previous errors
4556

0 commit comments

Comments
 (0)