diff options
| author | AnthonyMikh <anthony.mikh@yandex.ru> | 2019-09-30 23:47:51 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-30 23:47:51 +0300 |
| commit | 7b4c5c62aaa86301c2f358623bf3bfee39e7beef (patch) | |
| tree | 2b1726d36069fea927def1dbab8e5e2d83e9afe1 /src/librustc_errors | |
| parent | 6b6a79b19004fa2a62f8d02db2625cd7da547abf (diff) | |
| download | rust-7b4c5c62aaa86301c2f358623bf3bfee39e7beef.tar.gz rust-7b4c5c62aaa86301c2f358623bf3bfee39e7beef.zip | |
Simplify `EmitterWriter::get_max_line_num`
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 1d060ff1338..6727f276759 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1022,15 +1022,11 @@ impl EmitterWriter { } fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize { - let primary = self.get_multispan_max_line_num(span); - let mut max = primary; - - for sub in children { - let sub_result = self.get_multispan_max_line_num(&sub.span); - max = std::cmp::max(sub_result, max); - } - max + children.iter() + .map(|sub| self.get_multispan_max_line_num(&sub.span)) + .max() + .unwrap_or(primary) } /// Adds a left margin to every line but the first, given a padding length and the label being |
