Skip to content

Commit 6b6a79b

Browse files
authored
Simplify EmitterWriter::get_multispan_max_line_num
1 parent 7dc953b commit 6b6a79b

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/librustc_errors/emitter.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -997,27 +997,27 @@ impl EmitterWriter {
997997
}
998998

999999
fn get_multispan_max_line_num(&mut self, msp: &MultiSpan) -> usize {
1000+
let sm = match self.sm {
1001+
Some(ref sm) => sm,
1002+
None => return 0,
1003+
};
1004+
10001005
let mut max = 0;
1001-
if let Some(ref sm) = self.sm {
1002-
for primary_span in msp.primary_spans() {
1003-
if !primary_span.is_dummy() {
1004-
let hi = sm.lookup_char_pos(primary_span.hi());
1005-
if hi.line > max {
1006-
max = hi.line;
1007-
}
1008-
}
1006+
for primary_span in msp.primary_spans() {
1007+
if !primary_span.is_dummy() {
1008+
let hi = sm.lookup_char_pos(primary_span.hi());
1009+
max = max(max, hi.line);
10091010
}
1010-
if !self.short_message {
1011-
for span_label in msp.span_labels() {
1012-
if !span_label.span.is_dummy() {
1013-
let hi = sm.lookup_char_pos(span_label.span.hi());
1014-
if hi.line > max {
1015-
max = hi.line;
1016-
}
1017-
}
1011+
}
1012+
if !self.short_message {
1013+
for span_label in msp.span_labels() {
1014+
if !span_label.span.is_dummy() {
1015+
let hi = sm.lookup_char_pos(span_label.span.hi());
1016+
max = max(max, hi.line);
10181017
}
10191018
}
10201019
}
1020+
10211021
max
10221022
}
10231023

0 commit comments

Comments
 (0)