Skip to content

Commit 9460fba

Browse files
committed
clippy_dev: check that all lints are registered with a lint pass
1 parent 8ab97f3 commit 9460fba

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

clippy_dev/src/update_lints.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::utils::{FileUpdater, UpdateMode, UpdateStatus, update_text_region_fn}
33
use itertools::Itertools;
44
use std::fmt::Write;
55
use std::path::Path;
6+
use std::process;
67

78
const GENERATED_FILE_COMMENT: &str = "// This file was generated by `cargo dev update_lints`.\n\
89
// Use that command to update this file and do not edit by hand.\n\
@@ -20,7 +21,24 @@ const DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.ht
2021
///
2122
/// Panics if a file path could not read from or then written to
2223
pub fn update(update_mode: UpdateMode) {
23-
generate_lint_files(update_mode, &ParsedData::collect());
24+
let mut data = ParsedData::collect();
25+
let mut is_missing = false;
26+
data.lint_registrations.sort_by(|x, y| x.name.cmp(&y.name));
27+
for (name, lint) in &data.lints {
28+
if matches!(lint.kind, LintKind::Active(_))
29+
&& data.lint_registrations.binary_search_by(|x| x.name.cmp(name)).is_err()
30+
{
31+
is_missing = true;
32+
eprint!(
33+
"error: lint `{name}` is not registered in a lint pass\n declared here: {}\n",
34+
lint.name_span.display(&data.source_map)
35+
);
36+
}
37+
}
38+
if is_missing {
39+
process::exit(1);
40+
}
41+
generate_lint_files(update_mode, &data);
2442
}
2543

2644
#[expect(clippy::too_many_lines)]

0 commit comments

Comments
 (0)