about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-09-24 23:45:31 +0200
committerGitHub <noreply@github.com>2019-09-24 23:45:31 +0200
commitbea19338d2ba3d34a94ffbe5704e00328d276209 (patch)
tree31f29ce32ba6df3c19ab3fd7c9767abeded44e23 /src/librustc_errors
parente861424562bed0209b0be51531d9cb3be8147f44 (diff)
parenta6da0e921b01352dbdf45320afc9e41f27ac5784 (diff)
downloadrust-bea19338d2ba3d34a94ffbe5704e00328d276209.tar.gz
rust-bea19338d2ba3d34a94ffbe5704e00328d276209.zip
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.
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/emitter.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index fc441320e00..2a89c94652a 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -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
     }