Rollup merge of #64721 - hman523:issue64447, r=estebank

Fixed issue from #64447

Did two tiny fixes. One is a micro optimization since we know that max is going to be assigned a `usize`, we do not have to worry about a possible negative number.
The other issue that was fixed is that the max from the children isn't updated correctly. Now it will use `sub_result` instead of `primary` and will properly get the needed value.
This commit is contained in:
Mazdak Farrokhzad 2019-09-24 23:45:31 +02:00 committed by GitHub
commit bea19338d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1043,14 +1043,13 @@ impl EmitterWriter {
}
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize {
let mut max = 0;
let primary = self.get_multispan_max_line_num(span);
max = if primary > max { primary } else { max };
let mut max = primary;
for sub in children {
let sub_result = self.get_multispan_max_line_num(&sub.span);
max = if sub_result > max { primary } else { max };
max = std::cmp::max(sub_result, max);
}
max
}