@@ -5,7 +5,7 @@ use crate::ty::{
5
5
TypeSuperFoldable ,
6
6
} ;
7
7
use rustc_apfloat:: ieee:: { Double , Single } ;
8
- use rustc_data_structures:: fx:: FxHashMap ;
8
+ use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
9
9
use rustc_data_structures:: sso:: SsoHashSet ;
10
10
use rustc_hir as hir;
11
11
use rustc_hir:: def:: { self , CtorKind , DefKind , Namespace } ;
@@ -779,8 +779,8 @@ pub trait PrettyPrinter<'tcx>:
779
779
// by looking up the projections associated with the def_id.
780
780
let bounds = self . tcx ( ) . bound_explicit_item_bounds ( def_id) ;
781
781
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 ( ) ;
784
784
let mut is_sized = false ;
785
785
786
786
for predicate in bounds. transpose_iter ( ) . map ( |e| e. map_bound ( |( p, _) | * p) ) {
@@ -856,7 +856,7 @@ pub trait PrettyPrinter<'tcx>:
856
856
p ! ( ")" ) ;
857
857
if let Term :: Ty ( ty) = return_ty. skip_binder ( ) {
858
858
if !ty. is_unit ( ) {
859
- p ! ( "-> " , print( return_ty) ) ;
859
+ p ! ( " -> " , print( return_ty) ) ;
860
860
}
861
861
}
862
862
p ! ( write( "{}" , if paren_needed { ")" } else { "" } ) ) ;
@@ -970,11 +970,11 @@ pub trait PrettyPrinter<'tcx>:
970
970
& mut self ,
971
971
trait_ref : ty:: PolyTraitRef < ' tcx > ,
972
972
proj_ty : Option < ( DefId , ty:: Binder < ' tcx , Term < ' tcx > > ) > ,
973
- traits : & mut BTreeMap <
973
+ traits : & mut FxIndexMap <
974
974
ty:: PolyTraitRef < ' tcx > ,
975
- BTreeMap < DefId , ty:: Binder < ' tcx , Term < ' tcx > > > ,
975
+ FxIndexMap < DefId , ty:: Binder < ' tcx , Term < ' tcx > > > ,
976
976
> ,
977
- fn_traits : & mut BTreeMap < ty:: PolyTraitRef < ' tcx > , OpaqueFnEntry < ' tcx > > ,
977
+ fn_traits : & mut FxIndexMap < ty:: PolyTraitRef < ' tcx > , OpaqueFnEntry < ' tcx > > ,
978
978
) {
979
979
let trait_def_id = trait_ref. def_id ( ) ;
980
980
@@ -1110,19 +1110,18 @@ pub trait PrettyPrinter<'tcx>:
1110
1110
// Builtin bounds.
1111
1111
// FIXME(eddyb) avoid printing twice (needed to ensure
1112
1112
// 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 ( ) ;
1115
1114
1116
1115
// The auto traits come ordered by `DefPathHash`. While
1117
1116
// `DefPathHash` is *stable* in the sense that it depends on
1118
1117
// neither the host nor the phase of the moon, it depends
1119
1118
// "pseudorandomly" on the compiler version and the target.
1120
1119
//
1121
- // To avoid that causing instabilities in compiletest
1120
+ // To avoid causing instabilities in compiletest
1122
1121
// output, sort the auto-traits alphabetically.
1123
- auto_traits. sort ( ) ;
1122
+ auto_traits. sort_by_cached_key ( |did| self . tcx ( ) . def_path_str ( * did ) ) ;
1124
1123
1125
- for ( _ , def_id) in auto_traits {
1124
+ for def_id in auto_traits {
1126
1125
if !first {
1127
1126
p ! ( " + " ) ;
1128
1127
}
0 commit comments