about summary refs log tree commit diff
path: root/src/tools/clippy/tests/config-consistency.rs
blob: 9e7ca26c7d40001cbed9be7fc67204b74f23f54f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
            );
        }
    }
}