From 9189f6034a61351f4b1e17937a49030358d63503 Mon Sep 17 00:00:00 2001 From: Liu Dingming Date: Mon, 28 Feb 2022 21:18:31 +0800 Subject: [PATCH] iter_with_drain dogfood --- clippy_lints/src/suspicious_operation_groupings.rs | 8 ++++---- .../src/utils/internal_lints/metadata_collector.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index c3d984fb5ae1..940a8428f779 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -399,9 +399,9 @@ fn if_statment_binops(kind: &ExprKind) -> Option>> { fn append_opt_vecs(target_opt: Option>, source_opt: Option>) -> Option> { match (target_opt, source_opt) { - (Some(mut target), Some(mut source)) => { + (Some(mut target), Some(source)) => { target.reserve(source.len()); - for op in source.drain(..) { + for op in source { target.push(op); } Some(target) @@ -436,9 +436,9 @@ fn chained_binops_helper<'expr>(left_outer: &'expr Expr, right_outer: &'expr Exp chained_binops_helper(left_left, left_right), chained_binops_helper(right_left, right_right), ) { - (Some(mut left_ops), Some(mut right_ops)) => { + (Some(mut left_ops), Some(right_ops)) => { left_ops.reserve(right_ops.len()); - for op in right_ops.drain(..) { + for op in right_ops { left_ops.push(op); } Some(left_ops) diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 56633490eaa1..a617422bbeb0 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -473,7 +473,7 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector { /// ``` fn check_expr(&mut self, cx: &LateContext<'hir>, expr: &'hir hir::Expr<'_>) { if let Some(args) = match_lint_emission(cx, expr) { - let mut emission_info = extract_emission_info(cx, args); + let emission_info = extract_emission_info(cx, args); if emission_info.is_empty() { // See: // - src/misc.rs:734:9 @@ -483,7 +483,7 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector { return; } - for (lint_name, applicability, is_multi_part) in emission_info.drain(..) { + for (lint_name, applicability, is_multi_part) in emission_info { let app_info = self.applicability_info.entry(lint_name).or_default(); app_info.applicability = applicability; app_info.is_multi_part_suggestion = is_multi_part; @@ -693,7 +693,7 @@ fn extract_emission_info<'hir>( } lints - .drain(..) + .into_iter() .map(|lint_name| (lint_name, applicability, multi_part)) .collect() }