Skip to content

Commit

Permalink
iter_with_drain dogfood
Browse files Browse the repository at this point in the history
  • Loading branch information
ldm0 committed Mar 1, 2022
1 parent 81823d4 commit 9189f60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/suspicious_operation_groupings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ fn if_statment_binops(kind: &ExprKind) -> Option<Vec<BinaryOp<'_>>> {

fn append_opt_vecs<A>(target_opt: Option<Vec<A>>, source_opt: Option<Vec<A>>) -> Option<Vec<A>> {
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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/utils/internal_lints/metadata_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -693,7 +693,7 @@ fn extract_emission_info<'hir>(
}

lints
.drain(..)
.into_iter()
.map(|lint_name| (lint_name, applicability, multi_part))
.collect()
}
Expand Down

0 comments on commit 9189f60

Please sign in to comment.