1
Fork 0

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
This commit is contained in:
bors 2021-11-06 20:14:37 +00:00
commit 0727994435
2 changed files with 6 additions and 6 deletions

View file

@ -2665,7 +2665,7 @@ impl<'tcx> UserTypeProjections {
mut self, mut self,
mut f: impl FnMut(UserTypeProjection) -> UserTypeProjection, mut f: impl FnMut(UserTypeProjection) -> UserTypeProjection,
) -> Self { ) -> Self {
self.contents = self.contents.drain(..).map(|(proj, span)| (f(proj), span)).collect(); self.contents = self.contents.into_iter().map(|(proj, span)| (f(proj), span)).collect();
self self
} }

View file

@ -333,7 +333,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
let candidates = self let candidates = self
.r .r
.lookup_import_candidates(ident, ns, &self.parent_scope, is_expected) .lookup_import_candidates(ident, ns, &self.parent_scope, is_expected)
.drain(..) .into_iter()
.filter(|ImportSuggestion { did, .. }| { .filter(|ImportSuggestion { did, .. }| {
match (did, res.and_then(|res| res.opt_def_id())) { match (did, res.and_then(|res| res.opt_def_id())) {
(Some(suggestion_did), Some(actual_did)) => *suggestion_did != actual_did, (Some(suggestion_did), Some(actual_did)) => *suggestion_did != actual_did,
@ -1554,7 +1554,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
if suggest_only_tuple_variants { if suggest_only_tuple_variants {
// Suggest only tuple variants regardless of whether they have fields and do not // Suggest only tuple variants regardless of whether they have fields and do not
// suggest path with added parentheses. // suggest path with added parentheses.
let mut suggestable_variants = variants let suggestable_variants = variants
.iter() .iter()
.filter(|(.., kind)| *kind == CtorKind::Fn) .filter(|(.., kind)| *kind == CtorKind::Fn)
.map(|(variant, ..)| path_names_to_string(variant)) .map(|(variant, ..)| path_names_to_string(variant))
@ -1580,7 +1580,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
err.span_suggestions( err.span_suggestions(
span, span,
&msg, &msg,
suggestable_variants.drain(..), suggestable_variants.into_iter(),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }
@ -1638,7 +1638,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
); );
} }
let mut suggestable_variants_with_placeholders = variants let suggestable_variants_with_placeholders = variants
.iter() .iter()
.filter(|(_, def_id, kind)| needs_placeholder(*def_id, *kind)) .filter(|(_, def_id, kind)| needs_placeholder(*def_id, *kind))
.map(|(variant, _, kind)| (path_names_to_string(variant), kind)) .map(|(variant, _, kind)| (path_names_to_string(variant), kind))
@ -1663,7 +1663,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
err.span_suggestions( err.span_suggestions(
span, span,
msg, msg,
suggestable_variants_with_placeholders.drain(..), suggestable_variants_with_placeholders.into_iter(),
Applicability::HasPlaceholders, Applicability::HasPlaceholders,
); );
} }