@@ -449,8 +449,11 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
449
449
assert_eq ! ( fcx_typeck_results. hir_owner, self . typeck_results. hir_owner) ;
450
450
let common_hir_owner = fcx_typeck_results. hir_owner ;
451
451
452
- for ( id, origin) in fcx_typeck_results. closure_kind_origins ( ) . iter ( ) {
453
- let hir_id = hir:: HirId { owner : common_hir_owner, local_id : * id } ;
452
+ let fcx_closure_kind_origins =
453
+ fcx_typeck_results. closure_kind_origins ( ) . items_in_stable_order ( self . tcx ( ) ) ;
454
+
455
+ for ( & local_id, origin) in fcx_closure_kind_origins {
456
+ let hir_id = hir:: HirId { owner : common_hir_owner, local_id } ;
454
457
let place_span = origin. 0 ;
455
458
let place = self . resolve ( origin. 1 . clone ( ) , & place_span) ;
456
459
self . typeck_results . closure_kind_origins_mut ( ) . insert ( hir_id, ( place_span, place) ) ;
@@ -477,22 +480,15 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
477
480
assert_eq ! ( fcx_typeck_results. hir_owner, self . typeck_results. hir_owner) ;
478
481
let common_hir_owner = fcx_typeck_results. hir_owner ;
479
482
480
- let mut errors_buffer = Vec :: new ( ) ;
481
- for ( & local_id, c_ty) in fcx_typeck_results. user_provided_types ( ) . iter ( ) {
482
- let hir_id = hir:: HirId { owner : common_hir_owner, local_id } ;
483
-
484
- if cfg ! ( debug_assertions) && c_ty. needs_infer ( ) {
485
- span_bug ! (
486
- hir_id. to_span( self . fcx. tcx) ,
487
- "writeback: `{:?}` has inference variables" ,
488
- c_ty
489
- ) ;
490
- } ;
483
+ if self . rustc_dump_user_substs {
484
+ let sorted_user_provided_types =
485
+ fcx_typeck_results. user_provided_types ( ) . items_in_stable_order ( self . tcx ( ) ) ;
491
486
492
- self . typeck_results . user_provided_types_mut ( ) . insert ( hir_id, * c_ty) ;
487
+ let mut errors_buffer = Vec :: new ( ) ;
488
+ for ( & local_id, c_ty) in sorted_user_provided_types {
489
+ let hir_id = hir:: HirId { owner : common_hir_owner, local_id } ;
493
490
494
- if let ty:: UserType :: TypeOf ( _, user_substs) = c_ty. value {
495
- if self . rustc_dump_user_substs {
491
+ if let ty:: UserType :: TypeOf ( _, user_substs) = c_ty. value {
496
492
// This is a unit-testing mechanism.
497
493
let span = self . tcx ( ) . hir ( ) . span ( hir_id) ;
498
494
// We need to buffer the errors in order to guarantee a consistent
@@ -504,31 +500,49 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
504
500
err. buffer ( & mut errors_buffer) ;
505
501
}
506
502
}
507
- }
508
503
509
- if !errors_buffer. is_empty ( ) {
510
- errors_buffer. sort_by_key ( |diag| diag. span . primary_span ( ) ) ;
511
- for mut diag in errors_buffer {
512
- self . tcx ( ) . sess . diagnostic ( ) . emit_diagnostic ( & mut diag) ;
504
+ if !errors_buffer. is_empty ( ) {
505
+ errors_buffer. sort_by_key ( |diag| diag. span . primary_span ( ) ) ;
506
+ for mut diag in errors_buffer {
507
+ self . tcx ( ) . sess . diagnostic ( ) . emit_diagnostic ( & mut diag) ;
508
+ }
513
509
}
514
510
}
511
+
512
+ self . typeck_results . user_provided_types_mut ( ) . extend (
513
+ fcx_typeck_results. user_provided_types ( ) . items ( ) . map ( |( local_id, c_ty) | {
514
+ let hir_id = hir:: HirId { owner : common_hir_owner, local_id } ;
515
+
516
+ if cfg ! ( debug_assertions) && c_ty. needs_infer ( ) {
517
+ span_bug ! (
518
+ hir_id. to_span( self . fcx. tcx) ,
519
+ "writeback: `{:?}` has inference variables" ,
520
+ c_ty
521
+ ) ;
522
+ } ;
523
+
524
+ ( hir_id, * c_ty)
525
+ } ) ,
526
+ ) ;
515
527
}
516
528
517
529
fn visit_user_provided_sigs ( & mut self ) {
518
530
let fcx_typeck_results = self . fcx . typeck_results . borrow ( ) ;
519
531
assert_eq ! ( fcx_typeck_results. hir_owner, self . typeck_results. hir_owner) ;
520
532
521
- for ( & def_id, c_sig) in fcx_typeck_results. user_provided_sigs . iter ( ) {
522
- if cfg ! ( debug_assertions) && c_sig. needs_infer ( ) {
523
- span_bug ! (
524
- self . fcx. tcx. def_span( def_id) ,
525
- "writeback: `{:?}` has inference variables" ,
526
- c_sig
527
- ) ;
528
- } ;
529
-
530
- self . typeck_results . user_provided_sigs . insert ( def_id, * c_sig) ;
531
- }
533
+ self . typeck_results . user_provided_sigs . extend (
534
+ fcx_typeck_results. user_provided_sigs . items ( ) . map ( |( & def_id, c_sig) | {
535
+ if cfg ! ( debug_assertions) && c_sig. needs_infer ( ) {
536
+ span_bug ! (
537
+ self . fcx. tcx. def_span( def_id) ,
538
+ "writeback: `{:?}` has inference variables" ,
539
+ c_sig
540
+ ) ;
541
+ } ;
542
+
543
+ ( def_id, * c_sig)
544
+ } ) ,
545
+ ) ;
532
546
}
533
547
534
548
fn visit_generator_interior_types ( & mut self ) {
@@ -647,7 +661,10 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
647
661
assert_eq ! ( fcx_typeck_results. hir_owner, self . typeck_results. hir_owner) ;
648
662
let common_hir_owner = fcx_typeck_results. hir_owner ;
649
663
650
- for ( & local_id, & fn_sig) in fcx_typeck_results. liberated_fn_sigs ( ) . iter ( ) {
664
+ let fcx_liberated_fn_sigs =
665
+ fcx_typeck_results. liberated_fn_sigs ( ) . items_in_stable_order ( self . tcx ( ) ) ;
666
+
667
+ for ( & local_id, & fn_sig) in fcx_liberated_fn_sigs {
651
668
let hir_id = hir:: HirId { owner : common_hir_owner, local_id } ;
652
669
let fn_sig = self . resolve ( fn_sig, & hir_id) ;
653
670
self . typeck_results . liberated_fn_sigs_mut ( ) . insert ( hir_id, fn_sig) ;
@@ -659,7 +676,10 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
659
676
assert_eq ! ( fcx_typeck_results. hir_owner, self . typeck_results. hir_owner) ;
660
677
let common_hir_owner = fcx_typeck_results. hir_owner ;
661
678
662
- for ( & local_id, ftys) in fcx_typeck_results. fru_field_types ( ) . iter ( ) {
679
+ let fcx_fru_field_types =
680
+ fcx_typeck_results. fru_field_types ( ) . items_in_stable_order ( self . tcx ( ) ) ;
681
+
682
+ for ( & local_id, ftys) in fcx_fru_field_types {
663
683
let hir_id = hir:: HirId { owner : common_hir_owner, local_id } ;
664
684
let ftys = self . resolve ( ftys. clone ( ) , & hir_id) ;
665
685
self . typeck_results . fru_field_types_mut ( ) . insert ( hir_id, ftys) ;
0 commit comments