Skip to content

Commit 2553a95

Browse files
committed
Replace boxed iterator with vec collect
1 parent cef19b8 commit 2553a95

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir as hir;
1313
use rustc_hir::def::DefKind;
1414
use rustc_hir::def_id::DefId;
1515
use rustc_hir::lang_items::LangItem;
16-
use rustc_hir::{Expr, ExprKind, Node, QPath};
16+
use rustc_hir::{ExprKind, Node, QPath};
1717
use rustc_infer::infer::{
1818
type_variable::{TypeVariableOrigin, TypeVariableOriginKind},
1919
RegionVariableOrigin,
@@ -475,29 +475,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
475475
let mut applicability = Applicability::MachineApplicable;
476476
let args = if let Some((receiver, args)) = args {
477477
// The first arg is the same kind as the receiver
478-
let it = if first_arg.is_some() {
479-
Box::new(std::iter::once(receiver).chain(args.iter()))
480-
as Box<dyn Iterator<Item = &Expr<'_>>>
478+
let explicit_args = if first_arg.is_some() {
479+
std::iter::once(receiver).chain(args.iter()).collect::<Vec<_>>()
481480
} else {
482481
// There is no `Self` kind to infer the arguments from
483482
if has_unsuggestable_args {
484483
applicability = Applicability::HasPlaceholders;
485484
}
486-
Box::new(args.iter()) as _
485+
args.iter().collect()
487486
};
488487
format!(
489488
"({}{})",
490489
first_arg.unwrap_or(""),
491-
it.map(|arg| tcx
492-
.sess
493-
.source_map()
494-
.span_to_snippet(arg.span)
495-
.unwrap_or_else(|_| {
496-
applicability = Applicability::HasPlaceholders;
497-
"_".to_owned()
498-
}))
499-
.collect::<Vec<_>>()
500-
.join(", "),
490+
explicit_args
491+
.iter()
492+
.map(|arg| tcx
493+
.sess
494+
.source_map()
495+
.span_to_snippet(arg.span)
496+
.unwrap_or_else(|_| {
497+
applicability = Applicability::HasPlaceholders;
498+
"_".to_owned()
499+
}))
500+
.collect::<Vec<_>>()
501+
.join(", "),
501502
)
502503
} else {
503504
applicability = Applicability::HasPlaceholders;

0 commit comments

Comments
 (0)