Skip to content

Commit e9a93be

Browse files
authored
Use max instead of ifs
1 parent 2cb460e commit e9a93be

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/librustc_errors/emitter.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,8 @@ impl Margin {
169169
fn right(&self, line_len: usize) -> usize {
170170
if line_len.saturating_sub(self.computed_left) <= self.column_width {
171171
line_len
172-
} else if self.computed_right > line_len {
173-
line_len
174172
} else {
175-
self.computed_right
173+
min(line_len, self.computed_right)
176174
}
177175
}
178176
}
@@ -797,9 +795,7 @@ impl EmitterWriter {
797795
}
798796
}
799797
}
800-
if line_len < p {
801-
line_len = p;
802-
}
798+
line_len = max(line_len, p);
803799
}
804800

805801
if line_len != 0 {
@@ -1772,9 +1768,7 @@ impl FileWithAnnotatedLines {
17721768

17731769
let mut max_depth = 0; // max overlapping multiline spans
17741770
for (file, ann) in multiline_annotations {
1775-
if ann.depth > max_depth {
1776-
max_depth = ann.depth;
1777-
}
1771+
max_depth = max(max_depth, ann.depth);
17781772
let mut end_ann = ann.as_end();
17791773
if !ann.overlaps_exactly {
17801774
// avoid output like

0 commit comments

Comments
 (0)