Skip to content

Commit 6b468be

Browse files
committed
Check that all configuration options reference existing lints
1 parent e7ca364 commit 6b468be

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/config-consistency.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#![feature(rustc_private)]
2+
3+
// This test checks that all lints defined in `clippy_config::conf` in `#[lints]`
4+
// attributes exist as Clippy lints.
5+
//
6+
// This test is a no-op if run as part of the compiler test suite
7+
// and will always succeed.
8+
9+
use std::collections::HashSet;
10+
11+
#[test]
12+
fn config_consistency() {
13+
if option_env!("RUSTC_TEST_SUITE").is_some() {
14+
return;
15+
}
16+
17+
let lint_names: HashSet<String> = clippy_lints::declared_lints::LINTS
18+
.iter()
19+
.map(|lint_info| lint_info.lint.name.strip_prefix("clippy::").unwrap().to_lowercase())
20+
.collect();
21+
for conf in clippy_config::get_configuration_metadata() {
22+
for lint in conf.lints {
23+
if !lint_names.contains(*lint) {
24+
panic!(
25+
"Configuration option {} references lint `{lint}` which does not exist",
26+
conf.name
27+
);
28+
}
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)