@@ -27,12 +27,13 @@ use rustc::ty::{self, ParamEnv, TyCtxt, Ty};
2727
2828use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder , Level } ;
2929use rustc_data_structures:: bit_set:: BitSet ;
30- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
30+ use rustc_data_structures:: fx:: FxHashSet ;
3131use rustc_data_structures:: graph:: dominators:: Dominators ;
3232use rustc_data_structures:: indexed_vec:: Idx ;
3333use smallvec:: SmallVec ;
3434
3535use std:: rc:: Rc ;
36+ use std:: collections:: BTreeMap ;
3637
3738use syntax_pos:: Span ;
3839
@@ -256,7 +257,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
256257 locals_are_invalidated_at_exit,
257258 access_place_error_reported : FxHashSet ( ) ,
258259 reservation_error_reported : FxHashSet ( ) ,
259- move_error_reported : FxHashMap ( ) ,
260+ move_error_reported : BTreeMap :: new ( ) ,
260261 uninitialized_error_reported : FxHashSet ( ) ,
261262 errors_buffer,
262263 nonlexical_regioncx : regioncx,
@@ -336,7 +337,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
336337 }
337338
338339 // Buffer any move errors that we collected and de-duplicated.
339- for ( _, ( _, diag) ) in mbcx. move_error_reported . drain ( ) {
340+ for ( _, ( _, diag) ) in mbcx. move_error_reported {
340341 diag. buffer ( & mut mbcx. errors_buffer ) ;
341342 }
342343
@@ -425,7 +426,11 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
425426 /// `Place` of the previous most diagnostic. This happens instead of buffering the error. Once
426427 /// all move errors have been reported, any diagnostics in this map are added to the buffer
427428 /// to be emitted.
428- move_error_reported : FxHashMap < Vec < MoveOutIndex > , ( Place < ' tcx > , DiagnosticBuilder < ' cx > ) > ,
429+ ///
430+ /// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary
431+ /// when errors in the map are being re-added to the error buffer so that errors with the
432+ /// same primary span come out in a consistent order.
433+ move_error_reported : BTreeMap < Vec < MoveOutIndex > , ( Place < ' tcx > , DiagnosticBuilder < ' cx > ) > ,
429434 /// This field keeps track of errors reported in the checking of uninitialized variables,
430435 /// so that we don't report seemingly duplicate errors.
431436 uninitialized_error_reported : FxHashSet < Place < ' tcx > > ,
0 commit comments