Check that all configuration options reference existing lints

This commit is contained in:
Samuel Tardieu 2025-08-02 23:52:39 +02:00
parent a7162e416e
commit 07b04a2e04
No known key found for this signature in database
GPG key ID: BDDC3208C6FEAFA8

View 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
);
}
}
}