Skip to content

Commit 7b4c5c6

Browse files
authored
Simplify EmitterWriter::get_max_line_num
1 parent 6b6a79b commit 7b4c5c6

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/librustc_errors/emitter.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,15 +1022,11 @@ impl EmitterWriter {
10221022
}
10231023

10241024
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize {
1025-
10261025
let primary = self.get_multispan_max_line_num(span);
1027-
let mut max = primary;
1028-
1029-
for sub in children {
1030-
let sub_result = self.get_multispan_max_line_num(&sub.span);
1031-
max = std::cmp::max(sub_result, max);
1032-
}
1033-
max
1026+
children.iter()
1027+
.map(|sub| self.get_multispan_max_line_num(&sub.span))
1028+
.max()
1029+
.unwrap_or(primary)
10341030
}
10351031

10361032
/// Adds a left margin to every line but the first, given a padding length and the label being

0 commit comments

Comments
 (0)