]> git.lizzy.rs Git - rust.git/commitdiff
Use vec![x; n] instead of iter::repeat(x).take(n).collect()
authorljedrz <ljedrz@gmail.com>
Tue, 30 Oct 2018 13:37:26 +0000 (14:37 +0100)
committerljedrz <ljedrz@gmail.com>
Tue, 30 Oct 2018 13:37:26 +0000 (14:37 +0100)
src/librustc/mir/interpret/mod.rs
src/librustc/traits/error_reporting.rs

index 62cc3113a3d37f6a9bfb70e70eac0bf91a9c7a56..61b5886e7832d86371236a28449ca2e2222c077a 100644 (file)
@@ -295,12 +295,10 @@ pub fn new_decoding_session(&self) -> AllocDecodingSession<'_> {
     }
 
     pub fn new(data_offsets: Vec<u32>) -> 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,
         }
     }
index 15a0adc3c06928ad8ebbe9542c61bc56011b40a2..b463faef1921ad966b24a97ac3b4e0494074d6c4 100644 (file)
@@ -34,7 +34,6 @@
 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 @@ pub fn report_arg_count_mismatch(
             // 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::<Vec<_>>()
-                                      .join(", ");
+                let underscores = vec!["_"; expected_args.len()].join(", ");
                 err.span_suggestion_with_applicability(
                     found_span,
                     &format!(