@@ -27,12 +27,13 @@ use rustc::ty::{self, ParamEnv, TyCtxt, Ty};
27
27
28
28
use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder , Level } ;
29
29
use rustc_data_structures:: bit_set:: BitSet ;
30
- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
30
+ use rustc_data_structures:: fx:: FxHashSet ;
31
31
use rustc_data_structures:: graph:: dominators:: Dominators ;
32
32
use rustc_data_structures:: indexed_vec:: Idx ;
33
33
use smallvec:: SmallVec ;
34
34
35
35
use std:: rc:: Rc ;
36
+ use std:: collections:: BTreeMap ;
36
37
37
38
use syntax_pos:: Span ;
38
39
@@ -256,7 +257,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
256
257
locals_are_invalidated_at_exit,
257
258
access_place_error_reported : FxHashSet ( ) ,
258
259
reservation_error_reported : FxHashSet ( ) ,
259
- move_error_reported : FxHashMap ( ) ,
260
+ move_error_reported : BTreeMap :: new ( ) ,
260
261
uninitialized_error_reported : FxHashSet ( ) ,
261
262
errors_buffer,
262
263
nonlexical_regioncx : regioncx,
@@ -336,7 +337,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
336
337
}
337
338
338
339
// 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 {
340
341
diag. buffer ( & mut mbcx. errors_buffer ) ;
341
342
}
342
343
@@ -425,7 +426,11 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
425
426
/// `Place` of the previous most diagnostic. This happens instead of buffering the error. Once
426
427
/// all move errors have been reported, any diagnostics in this map are added to the buffer
427
428
/// 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 > ) > ,
429
434
/// This field keeps track of errors reported in the checking of uninitialized variables,
430
435
/// so that we don't report seemingly duplicate errors.
431
436
uninitialized_error_reported : FxHashSet < Place < ' tcx > > ,
0 commit comments