about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-08-02 23:52:39 +0200
committerSamuel Tardieu <sam@rfc1149.net>2025-08-03 00:07:25 +0200
commit07b04a2e04348283acf9565f3de2c500cce4df9a (patch)
tree53c2907e9e523093ef53b0fb76c6fc1bf8dc6f5a
parenta7162e416e73afd4fc4c72f171b8166bb9d35b8c (diff)
downloadrust-07b04a2e04348283acf9565f3de2c500cce4df9a.tar.gz
rust-07b04a2e04348283acf9565f3de2c500cce4df9a.zip
Check that all configuration options reference existing lints
-rw-r--r--tests/config-consistency.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/config-consistency.rs b/tests/config-consistency.rs
new file mode 100644
index 00000000000..9e7ca26c7d4
--- /dev/null
+++ b/tests/config-consistency.rs
@@ -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
+            );
+        }
+    }
+}