about summary refs log tree commit diff
diff options
context:
space:
mode:
authorShotaro Yamada <sinkuu@sinkuu.xyz>2018-03-16 22:35:26 +0900
committerShotaro Yamada <sinkuu@sinkuu.xyz>2018-07-27 23:26:36 +0900
commit8296699faed63f713735fbfac53c0325ce45954e (patch)
treec75befe75ce530a55b7bc1e15719972c9d796cfd
parent3525368a562435622c3c8f293354805e6961b0bf (diff)
downloadrust-8296699faed63f713735fbfac53c0325ce45954e.tar.gz
rust-8296699faed63f713735fbfac53c0325ce45954e.zip
Remove unnecessary `.collect()`
-rw-r--r--src/librustc/infer/error_reporting/mod.rs2
-rw-r--r--src/librustc_errors/emitter.rs4
-rw-r--r--src/librustc_errors/lib.rs5
-rw-r--r--src/librustc_lint/bad_style.rs8
-rw-r--r--src/librustc_resolve/lib.rs4
5 files changed, 9 insertions, 14 deletions
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index 4ad60f2f85e..c46492895dd 100644
--- a/src/librustc/infer/error_reporting/mod.rs
+++ b/src/librustc/infer/error_reporting/mod.rs
@@ -805,7 +805,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                     //     Foo<_, Qux>
                     //         ^ elided type as this type argument was the same in both sides
                     let type_arguments = sub1.types().zip(sub2.types());
-                    let regions_len = sub1.regions().collect::<Vec<_>>().len();
+                    let regions_len = sub1.regions().count();
                     for (i, (ta1, ta2)) in type_arguments.take(len).enumerate() {
                         let i = i + regions_len;
                         if ta1 == ta2 {
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index a392278cab9..e0ed89a6416 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -528,9 +528,7 @@ impl EmitterWriter {
 
         // If there are no annotations or the only annotations on this line are
         // MultilineLine, then there's only code being shown, stop processing.
-        if line.annotations.is_empty() || line.annotations.iter()
-            .filter(|a| !a.is_line()).collect::<Vec<_>>().len() == 0
-        {
+        if line.annotations.iter().all(|a| a.is_line()) {
             return vec![];
         }
 
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index c0f07645f49..400e5829d33 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -610,9 +610,8 @@ impl Handler {
         if can_show_explain && are_there_diagnostics {
             let mut error_codes =
                 self.emitted_diagnostic_codes.borrow()
-                                             .clone()
-                                             .into_iter()
-                                             .filter_map(|x| match x {
+                                             .iter()
+                                             .filter_map(|x| match *x {
                                                  DiagnosticId::Error(ref s) => Some(s.clone()),
                                                  _ => None,
                                              })
diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs
index fd5a152311d..09871c0e840 100644
--- a/src/librustc_lint/bad_style.rs
+++ b/src/librustc_lint/bad_style.rs
@@ -83,12 +83,10 @@ impl NonCamelCaseTypes {
                     } else {
                         c.to_lowercase().collect()
                     })
-                    .collect::<Vec<_>>()
-                    .concat()
+                    .collect::<String>()
                 })
                 .filter(|x| !x.is_empty())
-                .collect::<Vec<_>>()
-                .iter().fold((String::new(), None), |(acc, prev): (String, Option<&String>), next| {
+                .fold((String::new(), None), |(acc, prev): (String, Option<String>), next| {
                     // separate two components with an underscore if their boundary cannot
                     // be distinguished using a uppercase/lowercase case distinction
                     let join = if let Some(prev) = prev {
@@ -96,7 +94,7 @@ impl NonCamelCaseTypes {
                                     let f = next.chars().next().unwrap();
                                     !char_has_case(l) && !char_has_case(f)
                                 } else { false };
-                    (acc + if join { "_" } else { "" } + next, Some(next))
+                    (acc + if join { "_" } else { "" } + &next, Some(next))
                 }).0
         }
 
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 765016fdc4a..d8b9c58950f 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -271,7 +271,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
             err
         }
         ResolutionError::VariableNotBoundInPattern(binding_error) => {
-            let target_sp = binding_error.target.iter().map(|x| *x).collect::<Vec<_>>();
+            let target_sp = binding_error.target.iter().cloned().collect::<Vec<_>>();
             let msp = MultiSpan::from_spans(target_sp.clone());
             let msg = format!("variable `{}` is not bound in all patterns", binding_error.name);
             let mut err = resolver.session.struct_span_err_with_code(
@@ -282,7 +282,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
             for sp in target_sp {
                 err.span_label(sp, format!("pattern doesn't bind `{}`", binding_error.name));
             }
-            let origin_sp = binding_error.origin.iter().map(|x| *x).collect::<Vec<_>>();
+            let origin_sp = binding_error.origin.iter().cloned();
             for sp in origin_sp {
                 err.span_label(sp, "variable not in all patterns");
             }