Skip to content

Commit e8c2995

Browse files
committed
Sort NLL error diagnostics by span in an attempt to make them match source order
(and thus, hopefully, more closely match user expectation).
1 parent 54628c8 commit e8c2995

File tree

1 file changed

+4
-0
lines changed
  • src/librustc_mir/borrow_check

1 file changed

+4
-0
lines changed

src/librustc_mir/borrow_check/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
331331
}
332332

333333
if mbcx.errors_buffer.len() > 0 {
334+
mbcx.errors_buffer.sort_by(|diag1, diag2| {
335+
diag1.span.primary_span().cmp(&diag2.span.primary_span())
336+
});
337+
334338
if tcx.migrate_borrowck() {
335339
match tcx.borrowck(def_id).signalled_any_error {
336340
SignalledError::NoErrorsSeen => {

0 commit comments

Comments
 (0)