Skip to content

Commit a5c2d0f

Browse files
committed
Auto merge of rust-lang#52764 - sinkuu:cleanup, r=nikomatsakis
Misc cleanups
2 parents fb0653e + e995a91 commit a5c2d0f

File tree

20 files changed

+50
-73
lines changed

20 files changed

+50
-73
lines changed

src/libcore/tests/num/dec2flt/parse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::iter;
1211
use core::num::dec2flt::parse::{Decimal, parse_decimal};
1312
use core::num::dec2flt::parse::ParseResult::{Valid, Invalid};
1413

@@ -46,7 +45,7 @@ fn valid() {
4645
assert_eq!(parse_decimal("1.e300"), Valid(Decimal::new(b"1", b"", 300)));
4746
assert_eq!(parse_decimal(".1e300"), Valid(Decimal::new(b"", b"1", 300)));
4847
assert_eq!(parse_decimal("101e-33"), Valid(Decimal::new(b"101", b"", -33)));
49-
let zeros: String = iter::repeat('0').take(25).collect();
48+
let zeros = "0".repeat(25);
5049
let s = format!("1.5e{}", zeros);
5150
assert_eq!(parse_decimal(&s), Valid(Decimal::new(b"1", b"5", 0)));
5251
}

src/librustc/dep_graph/dep_node.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,8 @@ macro_rules! define_dep_nodes {
334334
pub fn extract_def_id(&self, tcx: TyCtxt) -> Option<DefId> {
335335
if self.kind.can_reconstruct_query_key() {
336336
let def_path_hash = DefPathHash(self.hash);
337-
if let Some(ref def_path_map) = tcx.def_path_hash_to_def_id.as_ref() {
338-
def_path_map.get(&def_path_hash).cloned()
339-
} else {
340-
None
341-
}
337+
tcx.def_path_hash_to_def_id.as_ref()?
338+
.get(&def_path_hash).cloned()
342339
} else {
343340
None
344341
}

src/librustc/dep_graph/graph.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,12 @@ impl DepGraph {
489489
}
490490

491491
pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
492-
self.data.as_ref().and_then(|t| t.dep_node_debug.borrow().get(&dep_node).cloned())
492+
self.data
493+
.as_ref()?
494+
.dep_node_debug
495+
.borrow()
496+
.get(&dep_node)
497+
.cloned()
493498
}
494499

495500
pub fn edge_deduplication_data(&self) -> (u64, u64) {

src/librustc/hir/pat_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
4747
let actual_len = self.len();
4848
EnumerateAndAdjust {
4949
enumerate: self.enumerate(),
50-
gap_pos: if let Some(gap_pos) = gap_pos { gap_pos } else { expected_len },
50+
gap_pos: gap_pos.unwrap_or(expected_len),
5151
gap_len: expected_len - actual_len,
5252
}
5353
}

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
805805
// Foo<_, Qux>
806806
// ^ elided type as this type argument was the same in both sides
807807
let type_arguments = sub1.types().zip(sub2.types());
808-
let regions_len = sub1.regions().collect::<Vec<_>>().len();
808+
let regions_len = sub1.regions().count();
809809
for (i, (ta1, ta2)) in type_arguments.take(len).enumerate() {
810810
let i = i + regions_len;
811811
if ta1 == ta2 {

src/librustc/util/common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::collections::HashMap;
1717
use std::ffi::CString;
1818
use std::fmt::Debug;
1919
use std::hash::{Hash, BuildHasher};
20-
use std::iter::repeat;
2120
use std::panic;
2221
use std::env;
2322
use std::path::Path;
@@ -219,7 +218,7 @@ fn print_time_passes_entry_internal(what: &str, dur: Duration) {
219218
None => "".to_owned(),
220219
};
221220
println!("{}time: {}{}\t{}",
222-
repeat(" ").take(indentation).collect::<String>(),
221+
" ".repeat(indentation),
223222
duration_to_secs_str(dur),
224223
mem_string,
225224
what);

src/librustc_codegen_llvm/back/symbol_export.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
206206
})
207207
.collect();
208208

209-
if let Some(_) = *tcx.sess.entry_fn.borrow() {
210-
let symbol_name = "main".to_string();
211-
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));
209+
if tcx.sess.entry_fn.borrow().is_some() {
210+
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new("main"));
212211

213212
symbols.push((exported_symbol, SymbolExportLevel::C));
214213
}

src/librustc_driver/lib.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ use std::error::Error;
9696
use std::ffi::OsString;
9797
use std::fmt::{self, Display};
9898
use std::io::{self, Read, Write};
99-
use std::iter::repeat;
10099
use std::mem;
101100
use std::panic;
102101
use std::path::{PathBuf, Path};
@@ -1227,7 +1226,7 @@ Available lint options:
12271226
fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
12281227
-> Vec<(&'static str, Vec<lint::LintId>)> {
12291228
let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect();
1230-
lints.sort_by_key(|ref l| l.0);
1229+
lints.sort_by_key(|l| l.0);
12311230
lints
12321231
}
12331232

@@ -1251,9 +1250,7 @@ Available lint options:
12511250
.max()
12521251
.unwrap_or(0);
12531252
let padded = |x: &str| {
1254-
let mut s = repeat(" ")
1255-
.take(max_name_len - x.chars().count())
1256-
.collect::<String>();
1253+
let mut s = " ".repeat(max_name_len - x.chars().count());
12571254
s.push_str(x);
12581255
s
12591256
};
@@ -1285,9 +1282,7 @@ Available lint options:
12851282
.unwrap_or(0));
12861283

12871284
let padded = |x: &str| {
1288-
let mut s = repeat(" ")
1289-
.take(max_name_len - x.chars().count())
1290-
.collect::<String>();
1285+
let mut s = " ".repeat(max_name_len - x.chars().count());
12911286
s.push_str(x);
12921287
s
12931288
};

src/librustc_driver/profile/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetr
208208
for (ref cons, ref qm) in counts.iter() {
209209
data.push((cons.clone(), qm.count.clone(), qm.dur_total.clone(), qm.dur_self.clone()));
210210
};
211-
data.sort_by_key(|&k| Reverse(k.3));
211+
data.sort_by_key(|k| Reverse(k.3));
212212
for (cons, count, dur_total, dur_self) in data {
213213
write!(count_file, "{}, {}, {}, {}\n",
214214
cons, count,

src/librustc_errors/emitter.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,7 @@ impl EmitterWriter {
528528

529529
// If there are no annotations or the only annotations on this line are
530530
// MultilineLine, then there's only code being shown, stop processing.
531-
if line.annotations.is_empty() || line.annotations.iter()
532-
.filter(|a| !a.is_line()).collect::<Vec<_>>().len() == 0
533-
{
531+
if line.annotations.iter().all(|a| a.is_line()) {
534532
return vec![];
535533
}
536534

@@ -901,9 +899,7 @@ impl EmitterWriter {
901899
// | | length of label
902900
// | magic `3`
903901
// `max_line_num_len`
904-
let padding = (0..padding + label.len() + 5)
905-
.map(|_| " ")
906-
.collect::<String>();
902+
let padding = " ".repeat(padding + label.len() + 5);
907903

908904
/// Return whether `style`, or the override if present and the style is `NoStyle`.
909905
fn style_or_override(style: Style, override_style: Option<Style>) -> Style {

0 commit comments

Comments
 (0)