Skip to content

Commit 9d82fb4

Browse files
committed
Lintcheck: More info on Diags without spans
1 parent 31fdc2e commit 9d82fb4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lintcheck/src/output.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ impl ClippyWarning {
7070
let rendered = diag.rendered.as_mut().unwrap();
7171
*rendered = strip_ansi_escapes::strip_str(&rendered);
7272

73-
let span = diag.spans.iter().find(|span| span.is_primary).unwrap();
73+
// Turns out that there are lints without spans... For example Rust's
74+
// `renamed_and_removed_lints` if the lint is given via the CLI.
75+
let span = diag
76+
.spans
77+
.iter()
78+
.find(|span| span.is_primary)
79+
.or(diag.spans.first())
80+
.unwrap_or_else(|| panic!("Diagnositc without span: {diag}"));
7481
let file = &span.file_name;
7582
let url = if let Some(src_split) = file.find("/src/") {
7683
// This removes the inital `target/lintcheck/sources/<crate>-<version>/`

0 commit comments

Comments
 (0)