Skip to content

Check config options in test suite #15397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -873,15 +873,13 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
* [`needless_borrow`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow)
* [`non_std_lazy_statics`](https://rust-lang.github.io/rust-clippy/master/index.html#non_std_lazy_statics)
* [`option_as_ref_deref`](https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref)
* [`option_map_unwrap_or`](https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or)
* [`ptr_as_ptr`](https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr)
* [`question_mark`](https://rust-lang.github.io/rust-clippy/master/index.html#question_mark)
* [`redundant_field_names`](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names)
* [`redundant_static_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes)
* [`repeat_vec_with_capacity`](https://rust-lang.github.io/rust-clippy/master/index.html#repeat_vec_with_capacity)
* [`same_item_push`](https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push)
* [`seek_from_current`](https://rust-lang.github.io/rust-clippy/master/index.html#seek_from_current)
* [`seek_rewind`](https://rust-lang.github.io/rust-clippy/master/index.html#seek_rewind)
* [`to_digit_is_some`](https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some)
* [`transmute_ptr_to_ref`](https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref)
* [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions)
Expand Down
2 changes: 0 additions & 2 deletions clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,15 +775,13 @@ define_Conf! {
needless_borrow,
non_std_lazy_statics,
option_as_ref_deref,
option_map_unwrap_or,
ptr_as_ptr,
question_mark,
redundant_field_names,
redundant_static_lifetimes,
repeat_vec_with_capacity,
same_item_push,
seek_from_current,
seek_rewind,
to_digit_is_some,
transmute_ptr_to_ref,
tuple_array_conversions,
Expand Down
30 changes: 30 additions & 0 deletions tests/config-consistency.rs
Original file line number Diff line number Diff line change
@@ -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
);
}
}
}