about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2018-07-31 14:30:46 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2018-07-31 14:30:46 +0200
commite8c29959cde82359283ba4b2e705f7c691538414 (patch)
treeb739d1c73e9a7f3294dd5581210cd6c568657f3d
parent54628c8ea844956f3f4f416b82067c634eb09f7b (diff)
downloadrust-e8c29959cde82359283ba4b2e705f7c691538414.tar.gz
rust-e8c29959cde82359283ba4b2e705f7c691538414.zip
Sort NLL error diagnostics by span in an attempt to make them match source order
(and thus, hopefully, more closely match user expectation).
-rw-r--r--src/librustc_mir/borrow_check/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index 4ba96f643b0..3b767bfdd40 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -331,6 +331,10 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
     }
 
     if mbcx.errors_buffer.len() > 0 {
+        mbcx.errors_buffer.sort_by(|diag1, diag2| {
+            diag1.span.primary_span().cmp(&diag2.span.primary_span())
+        });
+
         if tcx.migrate_borrowck() {
             match tcx.borrowck(def_id).signalled_any_error {
                 SignalledError::NoErrorsSeen => {