Skip to content

Commit 6f5ace2

Browse files
committed
rustdoc: Link to the docs on namespaces when an unknown disambiguator is found
1 parent e5f83d2 commit 6f5ace2

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,10 @@ fn disambiguator_error(
20172017
msg: &str,
20182018
) {
20192019
diag_info.link_range = disambiguator_range;
2020-
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |_diag, _sp| {});
2020+
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp| {
2021+
let msg = "see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators";
2022+
diag.note(msg);
2023+
});
20212024
}
20222025

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

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

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)