Skip to content

Commit 8c20501

Browse files
Mark-Simulacrumflip1995
authored andcommitted
Update clippy_dev
1 parent 7e77f3c commit 8c20501

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

clippy_dev/src/lib.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
8282
if l.is_internal() || l.deprecation.is_some() {
8383
None
8484
} else {
85-
Some(format!(" {}::{},", l.module, l.name.to_uppercase()))
85+
Some(format!(" LintId::of(&{}::{}),", l.module, l.name.to_uppercase()))
8686
}
8787
})
8888
.sorted()
@@ -143,6 +143,20 @@ pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
143143
.collect::<Vec<String>>()
144144
}
145145

146+
pub fn gen_register_lint_list(lints: &[Lint]) -> Vec<String> {
147+
let pre = " store.register_lints(&[".to_string();
148+
let post = " ]);".to_string();
149+
let mut inner = lints
150+
.iter()
151+
.filter(|l| !(l.is_internal() || l.deprecation.is_some()))
152+
.map(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
153+
.sorted()
154+
.collect::<Vec<String>>();
155+
inner.insert(0, pre);
156+
inner.push(post);
157+
inner
158+
}
159+
146160
/// Gathers all files in `src/clippy_lints` and gathers all lints inside
147161
pub fn gather_all() -> impl Iterator<Item = Lint> {
148162
lint_files().flat_map(|f| gather_from_file(&f))
@@ -487,8 +501,8 @@ fn test_gen_lint_group_list() {
487501
Lint::new("incorrect_internal", "internal_style", "abc", None, "module_name"),
488502
];
489503
let expected = vec![
490-
" module_name::ABC,".to_string(),
491-
" module_name::SHOULD_ASSERT_EQ,".to_string(),
504+
" LintId::of(&module_name::ABC),".to_string(),
505+
" LintId::of(&module_name::SHOULD_ASSERT_EQ),".to_string(),
492506
];
493507
assert_eq!(expected, gen_lint_group_list(lints));
494508
}

clippy_dev/src/main.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn main() {
6767
match matches.subcommand() {
6868
("fmt", Some(matches)) => {
6969
fmt::run(matches.is_present("check"), matches.is_present("verbose"));
70-
},
70+
}
7171
("update_lints", Some(matches)) => {
7272
if matches.is_present("print-only") {
7373
print_lints();
@@ -76,8 +76,8 @@ fn main() {
7676
} else {
7777
update_lints(&UpdateMode::Change);
7878
}
79-
},
80-
_ => {},
79+
}
80+
_ => {}
8181
}
8282
}
8383

@@ -170,6 +170,16 @@ fn update_lints(update_mode: &UpdateMode) {
170170
)
171171
.changed;
172172

173+
file_change |= replace_region_in_file(
174+
"../clippy_lints/src/lib.rs",
175+
"begin register lints",
176+
"end register lints",
177+
false,
178+
update_mode == &UpdateMode::Change,
179+
|| gen_register_lint_list(&lint_list),
180+
)
181+
.changed;
182+
173183
file_change |= replace_region_in_file(
174184
"../clippy_lints/src/lib.rs",
175185
"begin lints modules",
@@ -183,7 +193,7 @@ fn update_lints(update_mode: &UpdateMode) {
183193
// Generate lists of lints in the clippy::all lint group
184194
file_change |= replace_region_in_file(
185195
"../clippy_lints/src/lib.rs",
186-
r#"reg.register_lint_group\("clippy::all""#,
196+
r#"store.register_group\(true, "clippy::all""#,
187197
r#"\]\);"#,
188198
false,
189199
update_mode == &UpdateMode::Change,
@@ -206,7 +216,7 @@ fn update_lints(update_mode: &UpdateMode) {
206216
for (lint_group, lints) in Lint::by_lint_group(&usable_lints) {
207217
file_change |= replace_region_in_file(
208218
"../clippy_lints/src/lib.rs",
209-
&format!("reg.register_lint_group\\(\"clippy::{}\"", lint_group),
219+
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),
210220
r#"\]\);"#,
211221
false,
212222
update_mode == &UpdateMode::Change,

0 commit comments

Comments
 (0)