Check that all configuration options reference existing lints
This commit is contained in:
parent
a7162e416e
commit
07b04a2e04
1 changed files with 30 additions and 0 deletions
30
tests/config-consistency.rs
Normal file
30
tests/config-consistency.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#![feature(rustc_private)]
|
||||
|
||||
// This test checks that all lints defined in `clippy_config::conf` in `#[lints]`
|
||||
// attributes exist as Clippy lints.
|
||||
//
|
||||
// This test is a no-op if run as part of the compiler test suite
|
||||
// and will always succeed.
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
fn config_consistency() {
|
||||
if option_env!("RUSTC_TEST_SUITE").is_some() {
|
||||
return;
|
||||
}
|
||||
|
||||
let lint_names: HashSet<String> = clippy_lints::declared_lints::LINTS
|
||||
.iter()
|
||||
.map(|lint_info| lint_info.lint.name.strip_prefix("clippy::").unwrap().to_lowercase())
|
||||
.collect();
|
||||
for conf in clippy_config::get_configuration_metadata() {
|
||||
for lint in conf.lints {
|
||||
assert!(
|
||||
lint_names.contains(*lint),
|
||||
"Configuration option {} references lint `{lint}` which does not exist",
|
||||
conf.name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue