Skip to content

Commit 0727994

Browse files
committed
Auto merge of #90655 - the8472:drain-dot-dot, r=jyn514
Replace some uses of vec.drain(..) with vec.into_iter() IntoIter should optimize better than Drain
2 parents 5ec7d1d + ff87ff9 commit 0727994

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2665,7 +2665,7 @@ impl<'tcx> UserTypeProjections {
26652665
mut self,
26662666
mut f: impl FnMut(UserTypeProjection) -> UserTypeProjection,
26672667
) -> Self {
2668-
self.contents = self.contents.drain(..).map(|(proj, span)| (f(proj), span)).collect();
2668+
self.contents = self.contents.into_iter().map(|(proj, span)| (f(proj), span)).collect();
26692669
self
26702670
}
26712671

compiler/rustc_resolve/src/late/diagnostics.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
333333
let candidates = self
334334
.r
335335
.lookup_import_candidates(ident, ns, &self.parent_scope, is_expected)
336-
.drain(..)
336+
.into_iter()
337337
.filter(|ImportSuggestion { did, .. }| {
338338
match (did, res.and_then(|res| res.opt_def_id())) {
339339
(Some(suggestion_did), Some(actual_did)) => *suggestion_did != actual_did,
@@ -1554,7 +1554,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
15541554
if suggest_only_tuple_variants {
15551555
// Suggest only tuple variants regardless of whether they have fields and do not
15561556
// suggest path with added parentheses.
1557-
let mut suggestable_variants = variants
1557+
let suggestable_variants = variants
15581558
.iter()
15591559
.filter(|(.., kind)| *kind == CtorKind::Fn)
15601560
.map(|(variant, ..)| path_names_to_string(variant))
@@ -1580,7 +1580,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
15801580
err.span_suggestions(
15811581
span,
15821582
&msg,
1583-
suggestable_variants.drain(..),
1583+
suggestable_variants.into_iter(),
15841584
Applicability::MaybeIncorrect,
15851585
);
15861586
}
@@ -1638,7 +1638,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
16381638
);
16391639
}
16401640

1641-
let mut suggestable_variants_with_placeholders = variants
1641+
let suggestable_variants_with_placeholders = variants
16421642
.iter()
16431643
.filter(|(_, def_id, kind)| needs_placeholder(*def_id, *kind))
16441644
.map(|(variant, _, kind)| (path_names_to_string(variant), kind))
@@ -1663,7 +1663,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
16631663
err.span_suggestions(
16641664
span,
16651665
msg,
1666-
suggestable_variants_with_placeholders.drain(..),
1666+
suggestable_variants_with_placeholders.into_iter(),
16671667
Applicability::HasPlaceholders,
16681668
);
16691669
}

0 commit comments

Comments
 (0)