@@ -5,7 +5,7 @@ use crate::ty::{
55 TypeSuperFoldable ,
66} ;
77use rustc_apfloat:: ieee:: { Double , Single } ;
8- use rustc_data_structures:: fx:: FxHashMap ;
8+ use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
99use rustc_data_structures:: sso:: SsoHashSet ;
1010use rustc_hir as hir;
1111use rustc_hir:: def:: { self , CtorKind , DefKind , Namespace } ;
@@ -779,8 +779,8 @@ pub trait PrettyPrinter<'tcx>:
779779 // by looking up the projections associated with the def_id.
780780 let bounds = self . tcx ( ) . bound_explicit_item_bounds ( def_id) ;
781781
782- let mut traits = BTreeMap :: new ( ) ;
783- let mut fn_traits = BTreeMap :: new ( ) ;
782+ let mut traits = FxIndexMap :: default ( ) ;
783+ let mut fn_traits = FxIndexMap :: default ( ) ;
784784 let mut is_sized = false ;
785785
786786 for predicate in bounds. transpose_iter ( ) . map ( |e| e. map_bound ( |( p, _) | * p) ) {
@@ -856,7 +856,7 @@ pub trait PrettyPrinter<'tcx>:
856856 p ! ( ")" ) ;
857857 if let Term :: Ty ( ty) = return_ty. skip_binder ( ) {
858858 if !ty. is_unit ( ) {
859- p ! ( "-> " , print( return_ty) ) ;
859+ p ! ( " -> " , print( return_ty) ) ;
860860 }
861861 }
862862 p ! ( write( "{}" , if paren_needed { ")" } else { "" } ) ) ;
@@ -970,11 +970,11 @@ pub trait PrettyPrinter<'tcx>:
970970 & mut self ,
971971 trait_ref : ty:: PolyTraitRef < ' tcx > ,
972972 proj_ty : Option < ( DefId , ty:: Binder < ' tcx , Term < ' tcx > > ) > ,
973- traits : & mut BTreeMap <
973+ traits : & mut FxIndexMap <
974974 ty:: PolyTraitRef < ' tcx > ,
975- BTreeMap < DefId , ty:: Binder < ' tcx , Term < ' tcx > > > ,
975+ FxIndexMap < DefId , ty:: Binder < ' tcx , Term < ' tcx > > > ,
976976 > ,
977- fn_traits : & mut BTreeMap < ty:: PolyTraitRef < ' tcx > , OpaqueFnEntry < ' tcx > > ,
977+ fn_traits : & mut FxIndexMap < ty:: PolyTraitRef < ' tcx > , OpaqueFnEntry < ' tcx > > ,
978978 ) {
979979 let trait_def_id = trait_ref. def_id ( ) ;
980980
@@ -1110,19 +1110,18 @@ pub trait PrettyPrinter<'tcx>:
11101110 // Builtin bounds.
11111111 // FIXME(eddyb) avoid printing twice (needed to ensure
11121112 // that the auto traits are sorted *and* printed via cx).
1113- let mut auto_traits: Vec < _ > =
1114- predicates. auto_traits ( ) . map ( |did| ( self . tcx ( ) . def_path_str ( did) , did) ) . collect ( ) ;
1113+ let mut auto_traits: Vec < _ > = predicates. auto_traits ( ) . collect ( ) ;
11151114
11161115 // The auto traits come ordered by `DefPathHash`. While
11171116 // `DefPathHash` is *stable* in the sense that it depends on
11181117 // neither the host nor the phase of the moon, it depends
11191118 // "pseudorandomly" on the compiler version and the target.
11201119 //
1121- // To avoid that causing instabilities in compiletest
1120+ // To avoid causing instabilities in compiletest
11221121 // output, sort the auto-traits alphabetically.
1123- auto_traits. sort ( ) ;
1122+ auto_traits. sort_by_cached_key ( |did| self . tcx ( ) . def_path_str ( * did ) ) ;
11241123
1125- for ( _ , def_id) in auto_traits {
1124+ for def_id in auto_traits {
11261125 if !first {
11271126 p ! ( " + " ) ;
11281127 }
0 commit comments