diff --git a/src/libcore/tests/num/dec2flt/parse.rs b/src/libcore/tests/num/dec2flt/parse.rs index 09acf2bc517b0..3ad694e38adb0 100644 --- a/src/libcore/tests/num/dec2flt/parse.rs +++ b/src/libcore/tests/num/dec2flt/parse.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::iter; use core::num::dec2flt::parse::{Decimal, parse_decimal}; use core::num::dec2flt::parse::ParseResult::{Valid, Invalid}; @@ -46,7 +45,7 @@ fn valid() { assert_eq!(parse_decimal("1.e300"), Valid(Decimal::new(b"1", b"", 300))); assert_eq!(parse_decimal(".1e300"), Valid(Decimal::new(b"", b"1", 300))); assert_eq!(parse_decimal("101e-33"), Valid(Decimal::new(b"101", b"", -33))); - let zeros: String = iter::repeat('0').take(25).collect(); + let zeros = "0".repeat(25); let s = format!("1.5e{}", zeros); assert_eq!(parse_decimal(&s), Valid(Decimal::new(b"1", b"5", 0))); } diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 78e57c6a5d78f..14a818ddafb71 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -334,11 +334,8 @@ macro_rules! define_dep_nodes { pub fn extract_def_id(&self, tcx: TyCtxt) -> Option { if self.kind.can_reconstruct_query_key() { let def_path_hash = DefPathHash(self.hash); - if let Some(ref def_path_map) = tcx.def_path_hash_to_def_id.as_ref() { - def_path_map.get(&def_path_hash).cloned() - } else { - None - } + tcx.def_path_hash_to_def_id.as_ref()? + .get(&def_path_hash).cloned() } else { None } diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 1721d1dd0e9c5..e308f2924a05c 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -489,7 +489,12 @@ impl DepGraph { } pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option { - self.data.as_ref().and_then(|t| t.dep_node_debug.borrow().get(&dep_node).cloned()) + self.data + .as_ref()? + .dep_node_debug + .borrow() + .get(&dep_node) + .cloned() } pub fn edge_deduplication_data(&self) -> (u64, u64) { diff --git a/src/librustc/hir/pat_util.rs b/src/librustc/hir/pat_util.rs index 14989f1ff7d8a..8a714a5fbd847 100644 --- a/src/librustc/hir/pat_util.rs +++ b/src/librustc/hir/pat_util.rs @@ -47,7 +47,7 @@ impl EnumerateAndAdjustIterator for T { let actual_len = self.len(); EnumerateAndAdjust { enumerate: self.enumerate(), - gap_pos: if let Some(gap_pos) = gap_pos { gap_pos } else { expected_len }, + gap_pos: gap_pos.unwrap_or(expected_len), gap_len: expected_len - actual_len, } } diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 4ad60f2f85e2c..c46492895dd21 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/util/common.rs b/src/librustc/util/common.rs index 85533caffce2e..857cabe18b1e2 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -17,7 +17,6 @@ use std::collections::HashMap; use std::ffi::CString; use std::fmt::Debug; use std::hash::{Hash, BuildHasher}; -use std::iter::repeat; use std::panic; use std::env; use std::path::Path; @@ -219,7 +218,7 @@ fn print_time_passes_entry_internal(what: &str, dur: Duration) { None => "".to_owned(), }; println!("{}time: {}{}\t{}", - repeat(" ").take(indentation).collect::(), + " ".repeat(indentation), duration_to_secs_str(dur), mem_string, what); diff --git a/src/librustc_codegen_llvm/back/symbol_export.rs b/src/librustc_codegen_llvm/back/symbol_export.rs index 94357f348497d..48de2f3beedfb 100644 --- a/src/librustc_codegen_llvm/back/symbol_export.rs +++ b/src/librustc_codegen_llvm/back/symbol_export.rs @@ -206,9 +206,8 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }) .collect(); - if let Some(_) = *tcx.sess.entry_fn.borrow() { - let symbol_name = "main".to_string(); - let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name)); + if tcx.sess.entry_fn.borrow().is_some() { + let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new("main")); symbols.push((exported_symbol, SymbolExportLevel::C)); } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 000025c49a698..3ec73059721a2 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -98,7 +98,6 @@ use std::error::Error; use std::ffi::OsString; use std::fmt::{self, Display}; use std::io::{self, Read, Write}; -use std::iter::repeat; use std::mem; use std::panic; use std::path::{PathBuf, Path}; @@ -1229,7 +1228,7 @@ Available lint options: fn sort_lint_groups(lints: Vec<(&'static str, Vec, bool)>) -> Vec<(&'static str, Vec)> { let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect(); - lints.sort_by_key(|ref l| l.0); + lints.sort_by_key(|l| l.0); lints } @@ -1253,9 +1252,7 @@ Available lint options: .max() .unwrap_or(0); let padded = |x: &str| { - let mut s = repeat(" ") - .take(max_name_len - x.chars().count()) - .collect::(); + let mut s = " ".repeat(max_name_len - x.chars().count()); s.push_str(x); s }; @@ -1287,9 +1284,7 @@ Available lint options: .unwrap_or(0)); let padded = |x: &str| { - let mut s = repeat(" ") - .take(max_name_len - x.chars().count()) - .collect::(); + let mut s = " ".repeat(max_name_len - x.chars().count()); s.push_str(x); s }; diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs index 4aaf5eb47f61c..970a860fdff2c 100644 --- a/src/librustc_driver/profile/trace.rs +++ b/src/librustc_driver/profile/trace.rs @@ -208,7 +208,7 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap>().len() == 0 - { + if line.annotations.iter().all(|a| a.is_line()) { return vec![]; } @@ -901,9 +899,7 @@ impl EmitterWriter { // | | length of label // | magic `3` // `max_line_num_len` - let padding = (0..padding + label.len() + 5) - .map(|_| " ") - .collect::(); + let padding = " ".repeat(padding + label.len() + 5); /// Return whether `style`, or the override if present and the style is `NoStyle`. fn style_or_override(style: Style, override_style: Option