@@ -7,7 +7,9 @@ use crate::errors::NoAssociatedItem;
77use crate :: Expectation ;
88use crate :: FnCtxt ;
99use 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 ;
1113use rustc_errors:: StashKey ;
1214use rustc_errors:: {
1315 pluralize, struct_span_err, Applicability , Diagnostic , DiagnosticBuilder , ErrorGuaranteed ,
@@ -31,6 +33,7 @@ use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
3133use rustc_middle:: ty:: print:: { with_crate_prefix, with_forced_trimmed_paths} ;
3234use rustc_middle:: ty:: IsSuggestable ;
3335use rustc_middle:: ty:: { self , GenericArgKind , Ty , TyCtxt , TypeVisitableExt } ;
36+ use rustc_span:: def_id:: DefIdSet ;
3437use rustc_span:: symbol:: { kw, sym, Ident } ;
3538use rustc_span:: Symbol ;
3639use rustc_span:: { edit_distance, source_map, ExpnKind , FileName , MacroKind , Span } ;
@@ -536,11 +539,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
536539 ) ) ;
537540 }
538541 } else if !unsatisfied_predicates. is_empty ( ) {
539- let mut type_params = FxHashMap :: default ( ) ;
542+ let mut type_params = FxIndexMap :: default ( ) ;
540543
541544 // Pick out the list of unimplemented traits on the receiver.
542545 // 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 ( ) ;
544547 let mut unimplemented_traits_only = true ;
545548 for ( predicate, _parent_pred, cause) in unsatisfied_predicates {
546549 if let ( ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( p) ) , Some ( cause) ) =
@@ -606,7 +609,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
606609 ) ;
607610 type_params
608611 . entry ( key)
609- . or_insert_with ( FxHashSet :: default)
612+ . or_insert_with ( UnordSet :: default)
610613 . insert ( obligation. to_owned ( ) ) ;
611614 return true ;
612615 }
@@ -680,8 +683,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
680683 } ;
681684
682685 // 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 ( ) ;
685688 for ( p, parent_p, cause) in unsatisfied_predicates {
686689 // Extract the predicate span and parent def id of the cause,
687690 // if we have one.
@@ -723,7 +726,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
723726 let span = self_ty. span . ctxt ( ) . outer_expn_data ( ) . call_site ;
724727 let entry = spanned_predicates. entry ( span) ;
725728 let entry = entry. or_insert_with ( || {
726- ( FxHashSet :: default ( ) , FxHashSet :: default ( ) , Vec :: new ( ) )
729+ ( FxIndexSet :: default ( ) , FxIndexSet :: default ( ) , Vec :: new ( ) )
727730 } ) ;
728731 entry. 0 . insert ( span) ;
729732 entry. 1 . insert ( (
@@ -771,7 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
771774 skip_list. insert ( p) ;
772775 let entry = spanned_predicates. entry ( self_ty. span ) ;
773776 let entry = entry. or_insert_with ( || {
774- ( FxHashSet :: default ( ) , FxHashSet :: default ( ) , Vec :: new ( ) )
777+ ( FxIndexSet :: default ( ) , FxIndexSet :: default ( ) , Vec :: new ( ) )
775778 } ) ;
776779 entry. 2 . push ( p) ;
777780 if cause_span != * item_span {
@@ -806,7 +809,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
806809 skip_list. insert ( p) ;
807810 let entry = spanned_predicates. entry ( ident. span ) ;
808811 let entry = entry. or_insert_with ( || {
809- ( FxHashSet :: default ( ) , FxHashSet :: default ( ) , Vec :: new ( ) )
812+ ( FxIndexSet :: default ( ) , FxIndexSet :: default ( ) , Vec :: new ( ) )
810813 } ) ;
811814 entry. 0 . insert ( cause_span) ;
812815 entry. 1 . insert ( ( ident. span , "" ) ) ;
@@ -840,7 +843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
840843 unsatisfied_bounds = true ;
841844 }
842845
843- let mut suggested_bounds = FxHashSet :: default ( ) ;
846+ let mut suggested_bounds = UnordSet :: default ( ) ;
844847 // The requirements that didn't have an `impl` span to show.
845848 let mut bound_list = unsatisfied_predicates
846849 . iter ( )
@@ -889,8 +892,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
889892 for ( ( span, add_where_or_comma) , obligations) in type_params. into_iter ( ) {
890893 restrict_type_params = true ;
891894 // #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 ( ) ;
894896 err. span_suggestion_verbose (
895897 span,
896898 format ! (
@@ -2053,7 +2055,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20532055 ty:: Adt ( def, _) => Some ( def. did ( ) ) ,
20542056 _ => None ,
20552057 } )
2056- . collect :: < FxHashSet < _ > > ( ) ;
2058+ . collect :: < FxIndexSet < _ > > ( ) ;
20572059 let mut spans: MultiSpan = def_ids
20582060 . iter ( )
20592061 . filter_map ( |def_id| {
@@ -2669,7 +2671,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26692671 Nothing ,
26702672 }
26712673 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
26732675 . bounds_for_param ( def_id)
26742676 . flat_map ( |bp| bp. bounds . iter ( ) )
26752677 . filter_map ( |bound| bound. trait_ref ( ) ?. trait_def_id ( ) )
0 commit comments