Use vec![x; n] instead of iter::repeat(x).take(n).collect()
This commit is contained in:
parent
b1ca3907e0
commit
d1e74a3356
@ -295,12 +295,10 @@ impl AllocDecodingState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(data_offsets: Vec<u32>) -> AllocDecodingState {
|
pub fn new(data_offsets: Vec<u32>) -> AllocDecodingState {
|
||||||
let decoding_state: Vec<_> = ::std::iter::repeat(Mutex::new(State::Empty))
|
let decoding_state = vec![Mutex::new(State::Empty); data_offsets.len()];
|
||||||
.take(data_offsets.len())
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
AllocDecodingState {
|
AllocDecodingState {
|
||||||
decoding_state: decoding_state,
|
decoding_state,
|
||||||
data_offsets,
|
data_offsets,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ use hir::def_id::DefId;
|
|||||||
use infer::{self, InferCtxt};
|
use infer::{self, InferCtxt};
|
||||||
use infer::type_variable::TypeVariableOrigin;
|
use infer::type_variable::TypeVariableOrigin;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter;
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use session::DiagnosticMessageId;
|
use session::DiagnosticMessageId;
|
||||||
use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable};
|
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).
|
// found arguments is empty (assume the user just wants to ignore args in this case).
|
||||||
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
|
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
|
||||||
if found_args.is_empty() && is_closure {
|
if found_args.is_empty() && is_closure {
|
||||||
let underscores = iter::repeat("_")
|
let underscores = vec!["_"; expected_args.len()].join(", ");
|
||||||
.take(expected_args.len())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(", ");
|
|
||||||
err.span_suggestion_with_applicability(
|
err.span_suggestion_with_applicability(
|
||||||
found_span,
|
found_span,
|
||||||
&format!(
|
&format!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user