diff options
| author | flip1995 <hello@philkrones.com> | 2020-02-11 11:07:38 +0100 |
|---|---|---|
| committer | flip1995 <hello@philkrones.com> | 2020-02-14 14:37:55 +0100 |
| commit | 560559bafe1d61bca3d815ce80c53ae2d48e1829 (patch) | |
| tree | fc8da0036fe959da93c329b64551e56ea0ac78d6 | |
| parent | 41d90d3b8e633ab53005b8f7459dd10e4526bd41 (diff) | |
| download | rust-560559bafe1d61bca3d815ce80c53ae2d48e1829.tar.gz rust-560559bafe1d61bca3d815ce80c53ae2d48e1829.zip | |
Make Lint::by_lint_group take impl Iterator as argument
| -rw-r--r-- | clippy_dev/src/lib.rs | 9 | ||||
| -rw-r--r-- | clippy_dev/src/main.rs | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 3acecf96791..67a9abd29d6 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -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] @@ -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] diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 15487681742..2808aafc690 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -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" { @@ -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), |
