From d1e74a3356b8e311aab171bf316560b2f3d7f5c8 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 30 Oct 2018 14:37:26 +0100 Subject: [PATCH] Use vec![x; n] instead of iter::repeat(x).take(n).collect() --- src/librustc/mir/interpret/mod.rs | 6 ++---- src/librustc/traits/error_reporting.rs | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 62cc3113a3d37..61b5886e7832d 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -295,12 +295,10 @@ impl AllocDecodingState { } pub fn new(data_offsets: Vec) -> AllocDecodingState { - let decoding_state: Vec<_> = ::std::iter::repeat(Mutex::new(State::Empty)) - .take(data_offsets.len()) - .collect(); + let decoding_state = vec![Mutex::new(State::Empty); data_offsets.len()]; AllocDecodingState { - decoding_state: decoding_state, + decoding_state, data_offsets, } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 15a0adc3c0692..b463faef1921a 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -34,7 +34,6 @@ use hir::def_id::DefId; use infer::{self, InferCtxt}; use infer::type_variable::TypeVariableOrigin; use std::fmt; -use std::iter; use syntax::ast; use session::DiagnosticMessageId; use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; @@ -1095,10 +1094,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // found arguments is empty (assume the user just wants to ignore args in this case). // For example, if `expected_args_length` is 2, suggest `|_, _|`. if found_args.is_empty() && is_closure { - let underscores = iter::repeat("_") - .take(expected_args.len()) - .collect::>() - .join(", "); + let underscores = vec!["_"; expected_args.len()].join(", "); err.span_suggestion_with_applicability( found_span, &format!(