Skip to content

Commit 1b76818

Browse files
committed
Make Lint::by_lint_group take impl Iterator as argument
1 parent 63f818e commit 1b76818

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

clippy_dev/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ impl Lint {
6363

6464
/// Returns the lints in a `HashMap`, grouped by the different lint groups
6565
#[must_use]
66-
pub fn by_lint_group(lints: &[Self]) -> HashMap<String, Vec<Self>> {
67-
lints
68-
.iter()
69-
.map(|lint| (lint.group.to_string(), lint.clone()))
70-
.into_group_map()
66+
pub fn by_lint_group(lints: impl Iterator<Item = Self>) -> HashMap<String, Vec<Self>> {
67+
lints.map(|lint| (lint.group.to_string(), lint)).into_group_map()
7168
}
7269

7370
#[must_use]
@@ -449,7 +446,7 @@ fn test_by_lint_group() {
449446
"group2".to_string(),
450447
vec![Lint::new("should_assert_eq2", "group2", "abc", None, "module_name")],
451448
);
452-
assert_eq!(expected, Lint::by_lint_group(&lints));
449+
assert_eq!(expected, Lint::by_lint_group(lints.into_iter()));
453450
}
454451

455452
#[test]

clippy_dev/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn print_lints() {
136136
let lint_list = gather_all();
137137
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list).collect();
138138
let lint_count = usable_lints.len();
139-
let grouped_by_lint_group = Lint::by_lint_group(&usable_lints);
139+
let grouped_by_lint_group = Lint::by_lint_group(usable_lints.into_iter());
140140

141141
for (lint_group, mut lints) in grouped_by_lint_group {
142142
if lint_group == "Deprecated" {
@@ -267,7 +267,7 @@ fn update_lints(update_mode: UpdateMode) {
267267
.changed;
268268

269269
// Generate the list of lints for all other lint groups
270-
for (lint_group, lints) in Lint::by_lint_group(&usable_lints) {
270+
for (lint_group, lints) in Lint::by_lint_group(usable_lints.into_iter()) {
271271
file_change |= replace_region_in_file(
272272
Path::new("clippy_lints/src/lib.rs"),
273273
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),

0 commit comments

Comments
 (0)