From 1bc49a97433e8f1048f78f3ff93ea6226a252909 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Sun, 1 Apr 2018 13:52:45 +0900 Subject: [PATCH] Simplify --- src/librustc_driver/lib.rs | 2 +- src/librustc_driver/profile/trace.rs | 2 +- src/librustc_mir/monomorphize/mod.rs | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index d896df151a7dc..3ec73059721a2 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1228,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 } 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(tcx: TyCtxt<'a, 'tcx, 'tcx>, mon (mono_item, mono_item.symbol_name(tcx)) }).collect(); - (&mut symbols[..]).sort_by_key(|&sym| sym.1); + symbols.sort_by_key(|sym| sym.1); - for pair in (&symbols[..]).windows(2) { + for pair in symbols.windows(2) { let sym1 = &pair[0].1; let sym2 = &pair[1].1; - if *sym1 == *sym2 { + if sym1 == sym2 { let mono_item1 = pair[0].0; let mono_item2 = pair[1].0; @@ -51,9 +51,7 @@ pub fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mon span2 }) } - (Some(span), None) | - (None, Some(span)) => Some(span), - _ => None + (span1, span2) => span1.or(span2), }; let error_message = format!("symbol `{}` is already defined", sym1);