Skip to content

Commit 2cdc54b

Browse files
Improve description of new rustdoc lints
1 parent 3406533 commit 2cdc54b

5 files changed

Lines changed: 16 additions & 19 deletions

File tree

src/librustdoc/lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ declare_rustdoc_lint! {
200200
/// This lint checks for uses of footnote references without definition.
201201
BROKEN_FOOTNOTE,
202202
Warn,
203-
"footnote reference with no associated definition"
203+
"detects footnote references with no associated definition"
204204
}
205205

206206
declare_rustdoc_lint! {
207207
/// This lint checks if all footnote definitions are used.
208208
UNUSED_FOOTNOTE_DEFINITION,
209209
Warn,
210-
"unused footnote definition"
210+
"detects unused footnote definitions"
211211
}
212212

213213
pub(crate) static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {

src/librustdoc/passes/lint/footnotes.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,18 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item, hir_id: HirId, dox: &
7171

7272
#[allow(rustc::potential_query_instability)]
7373
for span in missing_footnote_references {
74-
let (ref_span, precise) =
74+
let (ref_span, _) =
7575
source_span_for_markdown_range(tcx, dox, &span, &item.attrs.doc_strings)
7676
.unwrap_or_else(|| (item.attr_span(tcx), false));
7777

78-
if precise {
79-
tcx.node_span_lint(crate::lint::BROKEN_FOOTNOTE, hir_id, ref_span, |lint| {
80-
lint.primary_message("no footnote definition matching this footnote");
81-
lint.span_suggestion(
82-
ref_span.shrink_to_lo(),
83-
"if it should not be a footnote, escape it",
84-
"\\",
85-
Applicability::MaybeIncorrect,
86-
);
87-
});
88-
}
78+
tcx.node_span_lint(crate::lint::BROKEN_FOOTNOTE, hir_id, ref_span, |lint| {
79+
lint.primary_message("no footnote definition matching this footnote");
80+
lint.span_suggestion(
81+
ref_span.shrink_to_lo(),
82+
"if it should not be a footnote, escape it",
83+
"\\",
84+
Applicability::MaybeIncorrect,
85+
);
86+
});
8987
}
9088
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(rustdoc::broken_footnote)]
2-
#![allow(rustdoc::unportable_markdown)]
32

43
//! Footnote referenced [^1]. And [^2]. And [^bla].
54
//!

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: no footnote definition matching this footnote
2-
--> $DIR/broken-footnote.rs:4:45
2+
--> $DIR/broken-footnote.rs:3:45
33
|
44
LL | //! Footnote referenced [^1]. And [^2]. And [^bla].
55
| -^^^^^
@@ -13,7 +13,7 @@ LL | #![deny(rustdoc::broken_footnote)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error: no footnote definition matching this footnote
16-
--> $DIR/broken-footnote.rs:4:35
16+
--> $DIR/broken-footnote.rs:3:35
1717
|
1818
LL | //! Footnote referenced [^1]. And [^2]. And [^bla].
1919
| -^^^
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// This test ensures that the rustdoc `unused_footnote` is working as expected.
1+
// This test ensures that the `rustdoc::unused_footnote` lint is working as expected.
22

33
#![deny(rustdoc::unused_footnote_definition)]
44

55
//! Footnote referenced. [^2]
66
//!
77
//! [^1]: footnote defined
88
//! [^2]: footnote defined
9-
//~^^ unused_footnote_definition
9+
//~^^ ERROR: unused footnote definition

0 commit comments

Comments
 (0)