diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8328a8385c31..6842f1fae496 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1311,10 +1311,12 @@ fn resolution_failure( diag } else { cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, - NodeId::new(0), - sp, - &msg) + NodeId::new(0), + sp, + &msg) }; + diag.help("to escape `[` and `]` characters, either put them into \"`[]`\" or \ + use HTML values `[` and `]`"); diag.emit(); } diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr index 3aa45405fd40..40a7427d733b 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -9,4 +9,5 @@ note: lint level defined here | 11 | #![deny(intra_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index 4949c450343c..d19ea93fa634 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -5,48 +5,63 @@ warning: `[Foo::baz]` cannot be resolved, ignoring it... | ^^^^^^^^ cannot be resolved, ignoring | = note: #[warn(intra_link_resolution_failure)] on by default + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Bar::foo]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:13:35 | 13 | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:13 | 14 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:30 | 14 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:14 | 16 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:31 | 16 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Qux:Y]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:18:13 | 18 | /// [Qux:Y] | ^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarA]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:24:10 | 24 | /// bar [BarA] bar | ^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarB]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:28:1 @@ -62,6 +77,7 @@ warning: `[BarB]` cannot be resolved, ignoring it... bar [BarB] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarC]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:35:1 @@ -79,6 +95,7 @@ warning: `[BarC]` cannot be resolved, ignoring it... bar [BarC] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarD]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:48:1 @@ -90,6 +107,7 @@ warning: `[BarD]` cannot be resolved, ignoring it... bar [BarD] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarF]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:53:9 @@ -104,4 +122,5 @@ warning: `[BarF]` cannot be resolved, ignoring it... bar [BarF] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]`