diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 4ad60f2f85e2..c46492895dd2 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::>().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 a392278cab98..e0ed89a64165 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::>().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 c0f07645f496..400e5829d333 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 fd5a152311de..09871c0e8404 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::>() - .concat() + .collect::() }) .filter(|x| !x.is_empty()) - .collect::>() - .iter().fold((String::new(), None), |(acc, prev): (String, Option<&String>), next| { + .fold((String::new(), None), |(acc, prev): (String, Option), 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 765016fdc4a7..d8b9c58950f5 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::>(); + let target_sp = binding_error.target.iter().cloned().collect::>(); 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::>(); + let origin_sp = binding_error.origin.iter().cloned(); for sp in origin_sp { err.span_label(sp, "variable not in all patterns"); }