Skip to content

Commit bea1933

Browse files
authored
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.
2 parents e861424 + a6da0e9 commit bea1933

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/librustc_errors/emitter.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1043,14 +1043,13 @@ impl EmitterWriter {
10431043
}
10441044

10451045
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize {
1046-
let mut max = 0;
10471046

10481047
let primary = self.get_multispan_max_line_num(span);
1049-
max = if primary > max { primary } else { max };
1048+
let mut max = primary;
10501049

10511050
for sub in children {
10521051
let sub_result = self.get_multispan_max_line_num(&sub.span);
1053-
max = if sub_result > max { primary } else { max };
1052+
max = std::cmp::max(sub_result, max);
10541053
}
10551054
max
10561055
}

0 commit comments

Comments
 (0)