mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 08:30:45 +00:00
Make Lint::by_lint_group take impl Iterator as argument
This commit is contained in:
parent
41d90d3b8e
commit
560559bafe
2 changed files with 5 additions and 8 deletions
|
@ -63,11 +63,8 @@ impl Lint {
|
||||||
|
|
||||||
/// Returns the lints in a `HashMap`, grouped by the different lint groups
|
/// Returns the lints in a `HashMap`, grouped by the different lint groups
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn by_lint_group(lints: &[Self]) -> HashMap<String, Vec<Self>> {
|
pub fn by_lint_group(lints: impl Iterator<Item = Self>) -> HashMap<String, Vec<Self>> {
|
||||||
lints
|
lints.map(|lint| (lint.group.to_string(), lint)).into_group_map()
|
||||||
.iter()
|
|
||||||
.map(|lint| (lint.group.to_string(), lint.clone()))
|
|
||||||
.into_group_map()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -449,7 +446,7 @@ fn test_by_lint_group() {
|
||||||
"group2".to_string(),
|
"group2".to_string(),
|
||||||
vec![Lint::new("should_assert_eq2", "group2", "abc", None, "module_name")],
|
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]
|
#[test]
|
||||||
|
|
|
@ -136,7 +136,7 @@ fn print_lints() {
|
||||||
let lint_list = gather_all();
|
let lint_list = gather_all();
|
||||||
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list).collect();
|
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list).collect();
|
||||||
let lint_count = usable_lints.len();
|
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 {
|
for (lint_group, mut lints) in grouped_by_lint_group {
|
||||||
if lint_group == "Deprecated" {
|
if lint_group == "Deprecated" {
|
||||||
|
@ -267,7 +267,7 @@ fn update_lints(update_mode: UpdateMode) {
|
||||||
.changed;
|
.changed;
|
||||||
|
|
||||||
// Generate the list of lints for all other lint groups
|
// 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(
|
file_change |= replace_region_in_file(
|
||||||
Path::new("clippy_lints/src/lib.rs"),
|
Path::new("clippy_lints/src/lib.rs"),
|
||||||
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),
|
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),
|
||||||
|
|
Loading…
Reference in a new issue