Skip to content

Commit c470ca8

Browse files
Improve suggestion for broken_footnote lint
1 parent 7b8b405 commit c470ca8

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/librustdoc/passes/lint/footnotes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item, hir_id: HirId, dox: &
8787
lint.span_suggestion(
8888
ref_span.shrink_to_lo(),
8989
"if it should not be a footnote, escape it",
90-
"\\",
90+
format!("\\{}", &dox[span]),
9191
Applicability::MaybeIncorrect,
9292
);
9393
}),

tests/rustdoc-ui/lints/broken-footnote.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: no footnote definition matching this footnote
44
LL | //! [^*] special characters can appear within footnote references
55
| -^^^
66
| |
7-
| help: if it should not be a footnote, escape it: `\`
7+
| help: if it should not be a footnote, escape it: `\[^*]`
88
|
99
note: the lint level is defined here
1010
--> $DIR/broken-footnote.rs:1:9
@@ -18,23 +18,23 @@ error: no footnote definition matching this footnote
1818
LL | //! Footnote referenced [^1]. And [^2]. And [^bla].
1919
| -^^^
2020
| |
21-
| help: if it should not be a footnote, escape it: `\`
21+
| help: if it should not be a footnote, escape it: `\[^2]`
2222

2323
error: no footnote definition matching this footnote
2424
--> $DIR/broken-footnote.rs:3:45
2525
|
2626
LL | //! Footnote referenced [^1]. And [^2]. And [^bla].
2727
| -^^^^^
2828
| |
29-
| help: if it should not be a footnote, escape it: `\`
29+
| help: if it should not be a footnote, escape it: `\[^bla]`
3030

3131
error: no footnote definition matching this footnote
3232
--> $DIR/broken-footnote.rs:16:5
3333
|
3434
LL | //! [^\_] so can escaped characters
3535
| -^^^^
3636
| |
37-
| help: if it should not be a footnote, escape it: `\`
37+
| help: if it should not be a footnote, escape it: `\[^\_]`
3838

3939
error: aborting due to 4 previous errors
4040

0 commit comments

Comments
 (0)