Skip to content

Commit ffb2e41

Browse files
committed
Clean up update_lints
1 parent 7907abe commit ffb2e41

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

clippy_dev/src/lib.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl Lint {
8585

8686
/// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
8787
#[must_use]
88-
pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
88+
pub fn gen_lint_group_list(lints: &[Lint]) -> Vec<String> {
8989
lints
9090
.into_iter()
9191
.filter_map(|l| {
@@ -101,14 +101,14 @@ pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
101101

102102
/// Generates the `pub mod module_name` list in `clippy_lints/src/lib.rs`.
103103
#[must_use]
104-
pub fn gen_modules_list(lints: Vec<Lint>) -> Vec<String> {
104+
pub fn gen_modules_list(lints: &[Lint]) -> Vec<String> {
105105
lints
106106
.into_iter()
107107
.filter_map(|l| {
108108
if l.is_internal() || l.deprecation.is_some() {
109109
None
110110
} else {
111-
Some(l.module)
111+
Some(l.module.clone())
112112
}
113113
})
114114
.unique()
@@ -119,11 +119,10 @@ pub fn gen_modules_list(lints: Vec<Lint>) -> Vec<String> {
119119

120120
/// Generates the list of lint links at the bottom of the README
121121
#[must_use]
122-
pub fn gen_changelog_lint_list(lints: Vec<Lint>) -> Vec<String> {
123-
let mut lint_list_sorted: Vec<Lint> = lints;
124-
lint_list_sorted.sort_by_key(|l| l.name.clone());
125-
lint_list_sorted
122+
pub fn gen_changelog_lint_list(lints: &[Lint]) -> Vec<String> {
123+
lints
126124
.iter()
125+
.sorted_by_key(|l| l.name.clone())
127126
.filter_map(|l| {
128127
if l.is_internal() {
129128
None
@@ -475,7 +474,7 @@ fn test_gen_changelog_lint_list() {
475474
format!("[`should_assert_eq`]: {}#should_assert_eq", DOCS_LINK.to_string()),
476475
format!("[`should_assert_eq2`]: {}#should_assert_eq2", DOCS_LINK.to_string()),
477476
];
478-
assert_eq!(expected, gen_changelog_lint_list(lints));
477+
assert_eq!(expected, gen_changelog_lint_list(&lints));
479478
}
480479

481480
#[test]
@@ -525,7 +524,7 @@ fn test_gen_modules_list() {
525524
"pub mod another_module;".to_string(),
526525
"pub mod module_name;".to_string(),
527526
];
528-
assert_eq!(expected, gen_modules_list(lints));
527+
assert_eq!(expected, gen_modules_list(&lints));
529528
}
530529

531530
#[test]
@@ -541,5 +540,5 @@ fn test_gen_lint_group_list() {
541540
" LintId::of(&module_name::INTERNAL),".to_string(),
542541
" LintId::of(&module_name::SHOULD_ASSERT_EQ),".to_string(),
543542
];
544-
assert_eq!(expected, gen_lint_group_list(lints));
543+
assert_eq!(expected, gen_lint_group_list(&lints));
545544
}

clippy_dev/src/update_lints.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn run(update_mode: UpdateMode) {
6161
"<!-- end autogenerated links to lint list -->",
6262
false,
6363
update_mode == UpdateMode::Change,
64-
|| gen_changelog_lint_list(lint_list.clone()),
64+
|| gen_changelog_lint_list(&lint_list),
6565
)
6666
.changed;
6767

@@ -91,7 +91,7 @@ pub fn run(update_mode: UpdateMode) {
9191
"end lints modules",
9292
false,
9393
update_mode == UpdateMode::Change,
94-
|| gen_modules_list(lint_list.clone()),
94+
|| gen_modules_list(&lint_list),
9595
)
9696
.changed;
9797

@@ -110,9 +110,9 @@ pub fn run(update_mode: UpdateMode) {
110110
.filter(|l| {
111111
l.group == "correctness" || l.group == "style" || l.group == "complexity" || l.group == "perf"
112112
})
113-
.collect();
113+
.collect::<Vec<_>>();
114114

115-
gen_lint_group_list(all_group_lints)
115+
gen_lint_group_list(&all_group_lints)
116116
},
117117
)
118118
.changed;
@@ -125,7 +125,7 @@ pub fn run(update_mode: UpdateMode) {
125125
r#"\]\);"#,
126126
false,
127127
update_mode == UpdateMode::Change,
128-
|| gen_lint_group_list(lints.clone()),
128+
|| gen_lint_group_list(&lints),
129129
)
130130
.changed;
131131
}

0 commit comments

Comments
 (0)