Skip to content

Commit 958e2e2

Browse files
committed
fix clippy-dev update_lints
1 parent 2838b04 commit 958e2e2

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

clippy_dev/src/lib.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,32 @@ pub fn gen_deprecated<'a>(lints: impl Iterator<Item = &'a Lint>) -> Vec<String>
146146
}
147147

148148
#[must_use]
149-
pub fn gen_register_lint_list<'a>(lints: impl Iterator<Item = &'a Lint>) -> Vec<String> {
150-
let pre = " store.register_lints(&[".to_string();
151-
let post = " ]);".to_string();
152-
let mut inner = lints
149+
pub fn gen_register_lint_list<'a>(
150+
internal_lints: impl Iterator<Item = &'a Lint>,
151+
usable_lints: impl Iterator<Item = &'a Lint>,
152+
) -> Vec<String> {
153+
let header = " store.register_lints(&[".to_string();
154+
let footer = " ]);".to_string();
155+
let internal_lints = internal_lints
156+
.sorted_by_key(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
157+
.map(|l| {
158+
format!(
159+
" #[cfg(feature = \"internal-lints\")]\n &{}::{},",
160+
l.module,
161+
l.name.to_uppercase()
162+
)
163+
})
164+
.collect::<Vec<String>>();
165+
let other_lints = usable_lints
166+
.sorted_by_key(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
153167
.map(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
154168
.sorted()
155169
.collect::<Vec<String>>();
156-
inner.insert(0, pre);
157-
inner.push(post);
158-
inner
170+
let mut lint_list = vec![header];
171+
lint_list.extend(internal_lints);
172+
lint_list.extend(other_lints);
173+
lint_list.push(footer);
174+
lint_list
159175
}
160176

161177
/// Gathers all files in `src/clippy_lints` and gathers all lints inside

clippy_dev/src/update_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn run(update_mode: UpdateMode) {
6868
"end register lints",
6969
false,
7070
update_mode == UpdateMode::Change,
71-
|| gen_register_lint_list(usable_lints.iter().chain(internal_lints.iter())),
71+
|| gen_register_lint_list(internal_lints.iter(), usable_lints.iter()),
7272
)
7373
.changed;
7474

clippy_lints/src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,24 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
498498

499499
// begin register lints, do not remove this comment, it’s used in `update_lints`
500500
store.register_lints(&[
501+
#[cfg(feature = "internal-lints")]
502+
&utils::internal_lints::CLIPPY_LINTS_INTERNAL,
503+
#[cfg(feature = "internal-lints")]
504+
&utils::internal_lints::COLLAPSIBLE_SPAN_LINT_CALLS,
505+
#[cfg(feature = "internal-lints")]
506+
&utils::internal_lints::COMPILER_LINT_FUNCTIONS,
507+
#[cfg(feature = "internal-lints")]
508+
&utils::internal_lints::DEFAULT_LINT,
509+
#[cfg(feature = "internal-lints")]
510+
&utils::internal_lints::INVALID_PATHS,
511+
#[cfg(feature = "internal-lints")]
512+
&utils::internal_lints::LINT_WITHOUT_LINT_PASS,
513+
#[cfg(feature = "internal-lints")]
514+
&utils::internal_lints::MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
515+
#[cfg(feature = "internal-lints")]
516+
&utils::internal_lints::OUTER_EXPN_EXPN_DATA,
517+
#[cfg(feature = "internal-lints")]
518+
&utils::internal_lints::PRODUCE_ICE,
501519
&approx_const::APPROX_CONSTANT,
502520
&arithmetic::FLOAT_ARITHMETIC,
503521
&arithmetic::INTEGER_ARITHMETIC,
@@ -904,24 +922,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
904922
&unwrap_in_result::UNWRAP_IN_RESULT,
905923
&use_self::USE_SELF,
906924
&useless_conversion::USELESS_CONVERSION,
907-
#[cfg(feature = "internal-lints")]
908-
&utils::internal_lints::CLIPPY_LINTS_INTERNAL,
909-
#[cfg(feature = "internal-lints")]
910-
&utils::internal_lints::COLLAPSIBLE_SPAN_LINT_CALLS,
911-
#[cfg(feature = "internal-lints")]
912-
&utils::internal_lints::COMPILER_LINT_FUNCTIONS,
913-
#[cfg(feature = "internal-lints")]
914-
&utils::internal_lints::DEFAULT_LINT,
915-
#[cfg(feature = "internal-lints")]
916-
&utils::internal_lints::INVALID_PATHS,
917-
#[cfg(feature = "internal-lints")]
918-
&utils::internal_lints::LINT_WITHOUT_LINT_PASS,
919-
#[cfg(feature = "internal-lints")]
920-
&utils::internal_lints::MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
921-
#[cfg(feature = "internal-lints")]
922-
&utils::internal_lints::OUTER_EXPN_EXPN_DATA,
923-
#[cfg(feature = "internal-lints")]
924-
&utils::internal_lints::PRODUCE_ICE,
925925
&vec::USELESS_VEC,
926926
&vec_resize_to_zero::VEC_RESIZE_TO_ZERO,
927927
&verbose_file_reads::VERBOSE_FILE_READS,

0 commit comments

Comments
 (0)