Clean up update_lints
This commit is contained in:
@@ -85,7 +85,7 @@ impl Lint {
|
|||||||
|
|
||||||
/// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
|
/// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
|
pub fn gen_lint_group_list(lints: &[Lint]) -> Vec<String> {
|
||||||
lints
|
lints
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|l| {
|
.filter_map(|l| {
|
||||||
@@ -101,14 +101,14 @@ pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
|
|||||||
|
|
||||||
/// Generates the `pub mod module_name` list in `clippy_lints/src/lib.rs`.
|
/// Generates the `pub mod module_name` list in `clippy_lints/src/lib.rs`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn gen_modules_list(lints: Vec<Lint>) -> Vec<String> {
|
pub fn gen_modules_list(lints: &[Lint]) -> Vec<String> {
|
||||||
lints
|
lints
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|l| {
|
.filter_map(|l| {
|
||||||
if l.is_internal() || l.deprecation.is_some() {
|
if l.is_internal() || l.deprecation.is_some() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(l.module)
|
Some(l.module.clone())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.unique()
|
.unique()
|
||||||
@@ -119,11 +119,10 @@ pub fn gen_modules_list(lints: Vec<Lint>) -> Vec<String> {
|
|||||||
|
|
||||||
/// Generates the list of lint links at the bottom of the README
|
/// Generates the list of lint links at the bottom of the README
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn gen_changelog_lint_list(lints: Vec<Lint>) -> Vec<String> {
|
pub fn gen_changelog_lint_list(lints: &[Lint]) -> Vec<String> {
|
||||||
let mut lint_list_sorted: Vec<Lint> = lints;
|
lints
|
||||||
lint_list_sorted.sort_by_key(|l| l.name.clone());
|
|
||||||
lint_list_sorted
|
|
||||||
.iter()
|
.iter()
|
||||||
|
.sorted_by_key(|l| l.name.clone())
|
||||||
.filter_map(|l| {
|
.filter_map(|l| {
|
||||||
if l.is_internal() {
|
if l.is_internal() {
|
||||||
None
|
None
|
||||||
@@ -475,7 +474,7 @@ fn test_gen_changelog_lint_list() {
|
|||||||
format!("[`should_assert_eq`]: {}#should_assert_eq", DOCS_LINK.to_string()),
|
format!("[`should_assert_eq`]: {}#should_assert_eq", DOCS_LINK.to_string()),
|
||||||
format!("[`should_assert_eq2`]: {}#should_assert_eq2", DOCS_LINK.to_string()),
|
format!("[`should_assert_eq2`]: {}#should_assert_eq2", DOCS_LINK.to_string()),
|
||||||
];
|
];
|
||||||
assert_eq!(expected, gen_changelog_lint_list(lints));
|
assert_eq!(expected, gen_changelog_lint_list(&lints));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -525,7 +524,7 @@ fn test_gen_modules_list() {
|
|||||||
"pub mod another_module;".to_string(),
|
"pub mod another_module;".to_string(),
|
||||||
"pub mod module_name;".to_string(),
|
"pub mod module_name;".to_string(),
|
||||||
];
|
];
|
||||||
assert_eq!(expected, gen_modules_list(lints));
|
assert_eq!(expected, gen_modules_list(&lints));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -541,5 +540,5 @@ fn test_gen_lint_group_list() {
|
|||||||
" LintId::of(&module_name::INTERNAL),".to_string(),
|
" LintId::of(&module_name::INTERNAL),".to_string(),
|
||||||
" LintId::of(&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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub fn run(update_mode: UpdateMode) {
|
|||||||
"<!-- end autogenerated links to lint list -->",
|
"<!-- end autogenerated links to lint list -->",
|
||||||
false,
|
false,
|
||||||
update_mode == UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_changelog_lint_list(lint_list.clone()),
|
|| gen_changelog_lint_list(&lint_list),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ pub fn run(update_mode: UpdateMode) {
|
|||||||
"end lints modules",
|
"end lints modules",
|
||||||
false,
|
false,
|
||||||
update_mode == UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_modules_list(lint_list.clone()),
|
|| gen_modules_list(&lint_list),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
|
|
||||||
@@ -110,9 +110,9 @@ pub fn run(update_mode: UpdateMode) {
|
|||||||
.filter(|l| {
|
.filter(|l| {
|
||||||
l.group == "correctness" || l.group == "style" || l.group == "complexity" || l.group == "perf"
|
l.group == "correctness" || l.group == "style" || l.group == "complexity" || l.group == "perf"
|
||||||
})
|
})
|
||||||
.collect();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
gen_lint_group_list(all_group_lints)
|
gen_lint_group_list(&all_group_lints)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
@@ -125,7 +125,7 @@ pub fn run(update_mode: UpdateMode) {
|
|||||||
r#"\]\);"#,
|
r#"\]\);"#,
|
||||||
false,
|
false,
|
||||||
update_mode == UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_lint_group_list(lints.clone()),
|
|| gen_lint_group_list(&lints),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user