diff options
| author | ljedrz <ljedrz@gmail.com> | 2018-07-25 10:36:57 +0200 |
|---|---|---|
| committer | ljedrz <ljedrz@gmail.com> | 2018-07-25 12:13:02 +0200 |
| commit | f653bf4fba40c6415b6f580c30fbcfe2e82cce62 (patch) | |
| tree | abcbdc4a509699c1c3ba0c2e53c43898767fc69b /src/librustc_errors | |
| parent | 13985724033467ab86da9136c43fe242092b294e (diff) | |
| download | rust-f653bf4fba40c6415b6f580c30fbcfe2e82cce62.tar.gz rust-f653bf4fba40c6415b6f580c30fbcfe2e82cce62.zip | |
Improve readability in a few sorts
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index c9b6818d5c1..6bcf0d9eff6 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -22,7 +22,7 @@ use std::borrow::Cow; use std::io::prelude::*; use std::io; use std::collections::HashMap; -use std::cmp::min; +use std::cmp::{min, Reverse}; use termcolor::{StandardStream, ColorChoice, ColorSpec, BufferWriter}; use termcolor::{WriteColor, Color, Buffer}; use unicode_width; @@ -265,9 +265,7 @@ impl EmitterWriter { } // Find overlapping multiline annotations, put them at different depths - multiline_annotations.sort_by(|a, b| { - (a.1.line_start, a.1.line_end).cmp(&(b.1.line_start, b.1.line_end)) - }); + multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, ml.line_end)); for item in multiline_annotations.clone() { let ann = item.1; for item in multiline_annotations.iter_mut() { @@ -403,7 +401,7 @@ impl EmitterWriter { // otherwise the lines would end up needing to go over a message. let mut annotations = line.annotations.clone(); - annotations.sort_by(|a,b| b.start_col.cmp(&a.start_col)); + annotations.sort_by_key(|a| Reverse(a.start_col)); // First, figure out where each label will be positioned. // |
