diff options
| author | AnthonyMikh <anthony.mikh@yandex.ru> | 2019-09-30 23:43:24 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-30 23:43:24 +0300 |
| commit | 6b6a79b19004fa2a62f8d02db2625cd7da547abf (patch) | |
| tree | b5a8f7d92e13af612df399c29e81009535bdea93 /src/librustc_errors | |
| parent | 7dc953b493d56f8b24f38d955cc580d9a14c1ae7 (diff) | |
| download | rust-6b6a79b19004fa2a62f8d02db2625cd7da547abf.tar.gz rust-6b6a79b19004fa2a62f8d02db2625cd7da547abf.zip | |
Simplify `EmitterWriter::get_multispan_max_line_num`
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index f17aee44e94..1d060ff1338 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -997,27 +997,27 @@ impl EmitterWriter { } fn get_multispan_max_line_num(&mut self, msp: &MultiSpan) -> usize { + let sm = match self.sm { + Some(ref sm) => sm, + None => return 0, + }; + let mut max = 0; - if let Some(ref sm) = self.sm { - for primary_span in msp.primary_spans() { - if !primary_span.is_dummy() { - let hi = sm.lookup_char_pos(primary_span.hi()); - if hi.line > max { - max = hi.line; - } - } + for primary_span in msp.primary_spans() { + if !primary_span.is_dummy() { + let hi = sm.lookup_char_pos(primary_span.hi()); + max = max(max, hi.line); } - if !self.short_message { - for span_label in msp.span_labels() { - if !span_label.span.is_dummy() { - let hi = sm.lookup_char_pos(span_label.span.hi()); - if hi.line > max { - max = hi.line; - } - } + } + if !self.short_message { + for span_label in msp.span_labels() { + if !span_label.span.is_dummy() { + let hi = sm.lookup_char_pos(span_label.span.hi()); + max = max(max, hi.line); } } } + max } |
