about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAnthonyMikh <anthony.mikh@yandex.ru>2019-09-25 23:08:09 +0300
committerGitHub <noreply@github.com>2019-09-25 23:08:09 +0300
commite9a93be53a6ccec5ba76f17333acf3c198313c61 (patch)
tree68f00af90c4f64235a737803c8866cb00f89dfb4
parent2cb460e6259af63924a719beaf91c5804dd0a789 (diff)
downloadrust-e9a93be53a6ccec5ba76f17333acf3c198313c61.tar.gz
rust-e9a93be53a6ccec5ba76f17333acf3c198313c61.zip
Use `max` instead of `if`s
-rw-r--r--src/librustc_errors/emitter.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index c5b03acb622..45c3dd8f4d8 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -169,10 +169,8 @@ impl Margin {
     fn right(&self, line_len: usize) -> usize {
         if line_len.saturating_sub(self.computed_left) <= self.column_width {
             line_len
-        } else if self.computed_right > line_len {
-            line_len
         } else {
-            self.computed_right
+            min(line_len, self.computed_right)
         }
     }
 }
@@ -797,9 +795,7 @@ impl EmitterWriter {
                     }
                 }
             }
-            if line_len < p {
-                line_len = p;
-            }
+            line_len = max(line_len, p);
         }
 
         if line_len != 0 {
@@ -1772,9 +1768,7 @@ impl FileWithAnnotatedLines {
 
         let mut max_depth = 0;  // max overlapping multiline spans
         for (file, ann) in multiline_annotations {
-            if ann.depth > max_depth {
-                max_depth = ann.depth;
-            }
+            max_depth = max(max_depth, ann.depth);
             let mut end_ann = ann.as_end();
             if !ann.overlaps_exactly {
                 // avoid output like