Skip to content

Commit 4ddd48c

Browse files
Improve description of new rustdoc lints
1 parent 621d984 commit 4ddd48c

3 files changed

Lines changed: 20 additions & 23 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: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,23 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item, hir_id: HirId, dox: &
7777

7878
#[allow(rustc::potential_query_instability)]
7979
for span in missing_footnote_references {
80-
let (ref_span, precise) =
81-
source_span_for_markdown_range(tcx, dox, &span, &item.attrs.doc_strings)
82-
.map(|(span, _)| (span, true))
83-
.unwrap_or_else(|| (item.attr_span(tcx), false));
80+
let ref_span = source_span_for_markdown_range(tcx, dox, &span, &item.attrs.doc_strings)
81+
.map(|(span, _)| span)
82+
.unwrap_or_else(|| item.attr_span(tcx));
8483

85-
if precise {
86-
tcx.emit_node_span_lint(
87-
crate::lint::BROKEN_FOOTNOTE,
88-
hir_id,
89-
ref_span,
90-
DiagDecorator(|lint| {
91-
lint.primary_message("no footnote definition matching this footnote");
92-
lint.span_suggestion(
93-
ref_span.shrink_to_lo(),
94-
"if it should not be a footnote, escape it",
95-
"\\",
96-
Applicability::MaybeIncorrect,
97-
);
98-
}),
99-
);
100-
}
84+
tcx.emit_node_span_lint(
85+
crate::lint::BROKEN_FOOTNOTE,
86+
hir_id,
87+
ref_span,
88+
DiagDecorator(|lint| {
89+
lint.primary_message("no footnote definition matching this footnote");
90+
lint.span_suggestion(
91+
ref_span.shrink_to_lo(),
92+
"if it should not be a footnote, escape it",
93+
"\\",
94+
Applicability::MaybeIncorrect,
95+
);
96+
}),
97+
);
10198
}
10299
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

0 commit comments

Comments
 (0)