Update clippy_dev
This commit is contained in:
@@ -82,7 +82,7 @@ pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
|
|||||||
if l.is_internal() || l.deprecation.is_some() {
|
if l.is_internal() || l.deprecation.is_some() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(format!(" {}::{},", l.module, l.name.to_uppercase()))
|
Some(format!(" LintId::of(&{}::{}),", l.module, l.name.to_uppercase()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.sorted()
|
.sorted()
|
||||||
@@ -143,6 +143,20 @@ pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
|
|||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn gen_register_lint_list(lints: &[Lint]) -> Vec<String> {
|
||||||
|
let pre = " store.register_lints(&[".to_string();
|
||||||
|
let post = " ]);".to_string();
|
||||||
|
let mut inner = lints
|
||||||
|
.iter()
|
||||||
|
.filter(|l| !(l.is_internal() || l.deprecation.is_some()))
|
||||||
|
.map(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
|
||||||
|
.sorted()
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
inner.insert(0, pre);
|
||||||
|
inner.push(post);
|
||||||
|
inner
|
||||||
|
}
|
||||||
|
|
||||||
/// Gathers all files in `src/clippy_lints` and gathers all lints inside
|
/// Gathers all files in `src/clippy_lints` and gathers all lints inside
|
||||||
pub fn gather_all() -> impl Iterator<Item = Lint> {
|
pub fn gather_all() -> impl Iterator<Item = Lint> {
|
||||||
lint_files().flat_map(|f| gather_from_file(&f))
|
lint_files().flat_map(|f| gather_from_file(&f))
|
||||||
@@ -487,8 +501,8 @@ fn test_gen_lint_group_list() {
|
|||||||
Lint::new("incorrect_internal", "internal_style", "abc", None, "module_name"),
|
Lint::new("incorrect_internal", "internal_style", "abc", None, "module_name"),
|
||||||
];
|
];
|
||||||
let expected = vec![
|
let expected = vec![
|
||||||
" module_name::ABC,".to_string(),
|
" LintId::of(&module_name::ABC),".to_string(),
|
||||||
" module_name::SHOULD_ASSERT_EQ,".to_string(),
|
" LintId::of(&module_name::SHOULD_ASSERT_EQ),".to_string(),
|
||||||
];
|
];
|
||||||
assert_eq!(expected, gen_lint_group_list(lints));
|
assert_eq!(expected, gen_lint_group_list(lints));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ fn main() {
|
|||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
("fmt", Some(matches)) => {
|
("fmt", Some(matches)) => {
|
||||||
fmt::run(matches.is_present("check"), matches.is_present("verbose"));
|
fmt::run(matches.is_present("check"), matches.is_present("verbose"));
|
||||||
},
|
}
|
||||||
("update_lints", Some(matches)) => {
|
("update_lints", Some(matches)) => {
|
||||||
if matches.is_present("print-only") {
|
if matches.is_present("print-only") {
|
||||||
print_lints();
|
print_lints();
|
||||||
@@ -76,8 +76,8 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
update_lints(&UpdateMode::Change);
|
update_lints(&UpdateMode::Change);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {},
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +170,16 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
|
|
||||||
|
file_change |= replace_region_in_file(
|
||||||
|
"../clippy_lints/src/lib.rs",
|
||||||
|
"begin register lints",
|
||||||
|
"end register lints",
|
||||||
|
false,
|
||||||
|
update_mode == &UpdateMode::Change,
|
||||||
|
|| gen_register_lint_list(&lint_list),
|
||||||
|
)
|
||||||
|
.changed;
|
||||||
|
|
||||||
file_change |= replace_region_in_file(
|
file_change |= replace_region_in_file(
|
||||||
"../clippy_lints/src/lib.rs",
|
"../clippy_lints/src/lib.rs",
|
||||||
"begin lints modules",
|
"begin lints modules",
|
||||||
@@ -183,7 +193,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
// Generate lists of lints in the clippy::all lint group
|
// Generate lists of lints in the clippy::all lint group
|
||||||
file_change |= replace_region_in_file(
|
file_change |= replace_region_in_file(
|
||||||
"../clippy_lints/src/lib.rs",
|
"../clippy_lints/src/lib.rs",
|
||||||
r#"reg.register_lint_group\("clippy::all""#,
|
r#"store.register_group\(true, "clippy::all""#,
|
||||||
r#"\]\);"#,
|
r#"\]\);"#,
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == &UpdateMode::Change,
|
||||||
@@ -206,7 +216,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
for (lint_group, lints) in Lint::by_lint_group(&usable_lints) {
|
for (lint_group, lints) in Lint::by_lint_group(&usable_lints) {
|
||||||
file_change |= replace_region_in_file(
|
file_change |= replace_region_in_file(
|
||||||
"../clippy_lints/src/lib.rs",
|
"../clippy_lints/src/lib.rs",
|
||||||
&format!("reg.register_lint_group\\(\"clippy::{}\"", lint_group),
|
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),
|
||||||
r#"\]\);"#,
|
r#"\]\);"#,
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == &UpdateMode::Change,
|
||||||
|
|||||||
Reference in New Issue
Block a user