@@ -7,7 +7,9 @@ use crate::errors::NoAssociatedItem;
7
7
use crate :: Expectation ;
8
8
use crate :: FnCtxt ;
9
9
use rustc_ast:: ast:: Mutability ;
10
- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
10
+ use rustc_data_structures:: fx:: FxIndexMap ;
11
+ use rustc_data_structures:: fx:: FxIndexSet ;
12
+ use rustc_data_structures:: unord:: UnordSet ;
11
13
use rustc_errors:: StashKey ;
12
14
use rustc_errors:: {
13
15
pluralize, struct_span_err, Applicability , Diagnostic , DiagnosticBuilder , ErrorGuaranteed ,
@@ -31,6 +33,7 @@ use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
31
33
use rustc_middle:: ty:: print:: { with_crate_prefix, with_forced_trimmed_paths} ;
32
34
use rustc_middle:: ty:: IsSuggestable ;
33
35
use rustc_middle:: ty:: { self , GenericArgKind , Ty , TyCtxt , TypeVisitableExt } ;
36
+ use rustc_span:: def_id:: DefIdSet ;
34
37
use rustc_span:: symbol:: { kw, sym, Ident } ;
35
38
use rustc_span:: Symbol ;
36
39
use rustc_span:: { edit_distance, source_map, ExpnKind , FileName , MacroKind , Span } ;
@@ -536,11 +539,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
536
539
) ) ;
537
540
}
538
541
} else if !unsatisfied_predicates. is_empty ( ) {
539
- let mut type_params = FxHashMap :: default ( ) ;
542
+ let mut type_params = FxIndexMap :: default ( ) ;
540
543
541
544
// Pick out the list of unimplemented traits on the receiver.
542
545
// This is used for custom error messages with the `#[rustc_on_unimplemented]` attribute.
543
- let mut unimplemented_traits = FxHashMap :: default ( ) ;
546
+ let mut unimplemented_traits = FxIndexMap :: default ( ) ;
544
547
let mut unimplemented_traits_only = true ;
545
548
for ( predicate, _parent_pred, cause) in unsatisfied_predicates {
546
549
if let ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( p) ) , Some ( cause) ) =
@@ -606,7 +609,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
606
609
) ;
607
610
type_params
608
611
. entry ( key)
609
- . or_insert_with ( FxHashSet :: default)
612
+ . or_insert_with ( UnordSet :: default)
610
613
. insert ( obligation. to_owned ( ) ) ;
611
614
return true ;
612
615
}
@@ -680,8 +683,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
680
683
} ;
681
684
682
685
// Find all the requirements that come from a local `impl` block.
683
- let mut skip_list: FxHashSet < _ > = Default :: default ( ) ;
684
- let mut spanned_predicates = FxHashMap :: default ( ) ;
686
+ let mut skip_list: UnordSet < _ > = Default :: default ( ) ;
687
+ let mut spanned_predicates = FxIndexMap :: default ( ) ;
685
688
for ( p, parent_p, cause) in unsatisfied_predicates {
686
689
// Extract the predicate span and parent def id of the cause,
687
690
// if we have one.
@@ -723,7 +726,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
723
726
let span = self_ty. span . ctxt ( ) . outer_expn_data ( ) . call_site ;
724
727
let entry = spanned_predicates. entry ( span) ;
725
728
let entry = entry. or_insert_with ( || {
726
- ( FxHashSet :: default ( ) , FxHashSet :: default ( ) , Vec :: new ( ) )
729
+ ( FxIndexSet :: default ( ) , FxIndexSet :: default ( ) , Vec :: new ( ) )
727
730
} ) ;
728
731
entry. 0 . insert ( span) ;
729
732
entry. 1 . insert ( (
@@ -771,7 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
771
774
skip_list. insert ( p) ;
772
775
let entry = spanned_predicates. entry ( self_ty. span ) ;
773
776
let entry = entry. or_insert_with ( || {
774
- ( FxHashSet :: default ( ) , FxHashSet :: default ( ) , Vec :: new ( ) )
777
+ ( FxIndexSet :: default ( ) , FxIndexSet :: default ( ) , Vec :: new ( ) )
775
778
} ) ;
776
779
entry. 2 . push ( p) ;
777
780
if cause_span != * item_span {
@@ -806,7 +809,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
806
809
skip_list. insert ( p) ;
807
810
let entry = spanned_predicates. entry ( ident. span ) ;
808
811
let entry = entry. or_insert_with ( || {
809
- ( FxHashSet :: default ( ) , FxHashSet :: default ( ) , Vec :: new ( ) )
812
+ ( FxIndexSet :: default ( ) , FxIndexSet :: default ( ) , Vec :: new ( ) )
810
813
} ) ;
811
814
entry. 0 . insert ( cause_span) ;
812
815
entry. 1 . insert ( ( ident. span , "" ) ) ;
@@ -840,7 +843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
840
843
unsatisfied_bounds = true ;
841
844
}
842
845
843
- let mut suggested_bounds = FxHashSet :: default ( ) ;
846
+ let mut suggested_bounds = UnordSet :: default ( ) ;
844
847
// The requirements that didn't have an `impl` span to show.
845
848
let mut bound_list = unsatisfied_predicates
846
849
. iter ( )
@@ -889,8 +892,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
889
892
for ( ( span, add_where_or_comma) , obligations) in type_params. into_iter ( ) {
890
893
restrict_type_params = true ;
891
894
// #74886: Sort here so that the output is always the same.
892
- let mut obligations = obligations. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
893
- obligations. sort ( ) ;
895
+ let obligations = obligations. to_sorted_stable_ord ( ) ;
894
896
err. span_suggestion_verbose (
895
897
span,
896
898
format ! (
@@ -2053,7 +2055,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2053
2055
ty:: Adt ( def, _) => Some ( def. did ( ) ) ,
2054
2056
_ => None ,
2055
2057
} )
2056
- . collect :: < FxHashSet < _ > > ( ) ;
2058
+ . collect :: < FxIndexSet < _ > > ( ) ;
2057
2059
let mut spans: MultiSpan = def_ids
2058
2060
. iter ( )
2059
2061
. filter_map ( |def_id| {
@@ -2669,7 +2671,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2669
2671
Nothing ,
2670
2672
}
2671
2673
let ast_generics = hir. get_generics ( id. owner . def_id ) . unwrap ( ) ;
2672
- let trait_def_ids: FxHashSet < DefId > = ast_generics
2674
+ let trait_def_ids: DefIdSet = ast_generics
2673
2675
. bounds_for_param ( def_id)
2674
2676
. flat_map ( |bp| bp. bounds . iter ( ) )
2675
2677
. filter_map ( |bound| bound. trait_ref ( ) ?. trait_def_id ( ) )
0 commit comments