Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make Lint::by_lint_group take impl Iterator as argument
  • Loading branch information
flip1995 committed Feb 14, 2020
commit 560559bafe1d61bca3d815ce80c53ae2d48e1829
9 changes: 3 additions & 6 deletions clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,8 @@ impl Lint {

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

#[must_use]
Expand Down Expand Up @@ -449,7 +446,7 @@ fn test_by_lint_group() {
"group2".to_string(),
vec![Lint::new("should_assert_eq2", "group2", "abc", None, "module_name")],
);
assert_eq!(expected, Lint::by_lint_group(&lints));
assert_eq!(expected, Lint::by_lint_group(lints.into_iter()));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn print_lints() {
let lint_list = gather_all();
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list).collect();
let lint_count = usable_lints.len();
let grouped_by_lint_group = Lint::by_lint_group(&usable_lints);
let grouped_by_lint_group = Lint::by_lint_group(usable_lints.into_iter());

for (lint_group, mut lints) in grouped_by_lint_group {
if lint_group == "Deprecated" {
Expand Down Expand Up @@ -267,7 +267,7 @@ fn update_lints(update_mode: UpdateMode) {
.changed;

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