From 2553a9590c5980a0013789209f928ec065e44ca6 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Mon, 26 Sep 2022 00:43:52 +0100 Subject: [PATCH] Replace boxed iterator with vec collect --- .../rustc_hir_typeck/src/method/suggest.rs | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 7ec3d4536606..237701b5e6fe 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -13,7 +13,7 @@ use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_hir::lang_items::LangItem; -use rustc_hir::{Expr, ExprKind, Node, QPath}; +use rustc_hir::{ExprKind, Node, QPath}; use rustc_infer::infer::{ type_variable::{TypeVariableOrigin, TypeVariableOriginKind}, RegionVariableOrigin, @@ -475,29 +475,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut applicability = Applicability::MachineApplicable; let args = if let Some((receiver, args)) = args { // The first arg is the same kind as the receiver - let it = if first_arg.is_some() { - Box::new(std::iter::once(receiver).chain(args.iter())) - as Box>> + let explicit_args = if first_arg.is_some() { + std::iter::once(receiver).chain(args.iter()).collect::>() } else { // There is no `Self` kind to infer the arguments from if has_unsuggestable_args { applicability = Applicability::HasPlaceholders; } - Box::new(args.iter()) as _ + args.iter().collect() }; format!( "({}{})", first_arg.unwrap_or(""), - it.map(|arg| tcx - .sess - .source_map() - .span_to_snippet(arg.span) - .unwrap_or_else(|_| { - applicability = Applicability::HasPlaceholders; - "_".to_owned() - })) - .collect::>() - .join(", "), + explicit_args + .iter() + .map(|arg| tcx + .sess + .source_map() + .span_to_snippet(arg.span) + .unwrap_or_else(|_| { + applicability = Applicability::HasPlaceholders; + "_".to_owned() + })) + .collect::>() + .join(", "), ) } else { applicability = Applicability::HasPlaceholders;