From fa2cfaf064ecda727fb922864a8eafbae1875228 Mon Sep 17 00:00:00 2001 From: hman523 Date: Mon, 23 Sep 2019 18:20:21 -0500 Subject: [PATCH 1/2] Fixed issue from #64447 --- src/librustc_errors/emitter.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index fc441320e0039..c13a4b8dbb487 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 = if sub_result > max { sub_result } else { max }; } max } From a6da0e921b01352dbdf45320afc9e41f27ac5784 Mon Sep 17 00:00:00 2001 From: hman523 Date: Mon, 23 Sep 2019 19:51:15 -0500 Subject: [PATCH 2/2] changed a line from an if else to std::cmp::max --- src/librustc_errors/emitter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index c13a4b8dbb487..2a89c94652a24 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1049,7 +1049,7 @@ impl EmitterWriter { for sub in children { let sub_result = self.get_multispan_max_line_num(&sub.span); - max = if sub_result > max { sub_result } else { max }; + max = std::cmp::max(sub_result, max); } max }