Skip to content

Commit

Permalink
Simplify EmitterWriter::get_max_line_num
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMikh committed Sep 30, 2019
1 parent 6b6a79b commit 7b4c5c6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/librustc_errors/emitter.rs
Expand Up @@ -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
Expand Down

0 comments on commit 7b4c5c6

Please sign in to comment.