Clean up update_lints

This commit is contained in:
flip1995 2020-04-02 18:20:23 +02:00
parent 7907abea27
commit ffb2e41234
No known key found for this signature in database
GPG key ID: 2CEFCDB27ED0BE79
2 changed files with 14 additions and 15 deletions

View file

@ -85,7 +85,7 @@ impl Lint {
/// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
#[must_use]
pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
pub fn gen_lint_group_list(lints: &[Lint]) -> Vec<String> {
lints
.into_iter()
.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`.
#[must_use]
pub fn gen_modules_list(lints: Vec<Lint>) -> Vec<String> {
pub fn gen_modules_list(lints: &[Lint]) -> Vec<String> {
lints
.into_iter()
.filter_map(|l| {
if l.is_internal() || l.deprecation.is_some() {
None
} else {
Some(l.module)
Some(l.module.clone())
}
})
.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
#[must_use]
pub fn gen_changelog_lint_list(lints: Vec<Lint>) -> Vec<String> {
let mut lint_list_sorted: Vec<Lint> = lints;
lint_list_sorted.sort_by_key(|l| l.name.clone());
lint_list_sorted
pub fn gen_changelog_lint_list(lints: &[Lint]) -> Vec<String> {
lints
.iter()
.sorted_by_key(|l| l.name.clone())
.filter_map(|l| {
if l.is_internal() {
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_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]
@ -525,7 +524,7 @@ fn test_gen_modules_list() {
"pub mod another_module;".to_string(),
"pub mod module_name;".to_string(),
];
assert_eq!(expected, gen_modules_list(lints));
assert_eq!(expected, gen_modules_list(&lints));
}
#[test]
@ -541,5 +540,5 @@ fn test_gen_lint_group_list() {
" LintId::of(&module_name::INTERNAL),".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));
}

View file

@ -61,7 +61,7 @@ pub fn run(update_mode: UpdateMode) {
"<!-- end autogenerated links to lint list -->",
false,
update_mode == UpdateMode::Change,
|| gen_changelog_lint_list(lint_list.clone()),
|| gen_changelog_lint_list(&lint_list),
)
.changed;
@ -91,7 +91,7 @@ pub fn run(update_mode: UpdateMode) {
"end lints modules",
false,
update_mode == UpdateMode::Change,
|| gen_modules_list(lint_list.clone()),
|| gen_modules_list(&lint_list),
)
.changed;
@ -110,9 +110,9 @@ pub fn run(update_mode: UpdateMode) {
.filter(|l| {
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;
@ -125,7 +125,7 @@ pub fn run(update_mode: UpdateMode) {
r#"\]\);"#,
false,
update_mode == UpdateMode::Change,
|| gen_lint_group_list(lints.clone()),
|| gen_lint_group_list(&lints),
)
.changed;
}