@@ -48,6 +48,7 @@ use std::path::PathBuf;
48
48
use std:: { fs, str} ;
49
49
50
50
use askama:: Template ;
51
+ use indexmap:: IndexMap ;
51
52
use itertools:: Either ;
52
53
use rustc_ast:: join_path_syms;
53
54
use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
@@ -60,8 +61,6 @@ use rustc_middle::ty::print::PrintTraitRefExt;
60
61
use rustc_middle:: ty:: { self , TyCtxt } ;
61
62
use rustc_span:: symbol:: { Symbol , sym} ;
62
63
use rustc_span:: { BytePos , DUMMY_SP , FileName , RealFileName } ;
63
- use serde:: ser:: SerializeMap ;
64
- use serde:: { Serialize , Serializer } ;
65
64
use tracing:: { debug, info} ;
66
65
67
66
pub ( crate ) use self :: context:: * ;
@@ -1722,23 +1721,9 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
1722
1721
}
1723
1722
1724
1723
fn notable_traits_json < ' a > ( tys : impl Iterator < Item = & ' a clean:: Type > , cx : & Context < ' _ > ) -> String {
1725
- let mut mp: Vec < ( String , String ) > = tys. map ( |ty| notable_traits_decl ( ty, cx) ) . collect ( ) ;
1726
- mp. sort_by ( |( name1, _html1) , ( name2, _html2) | name1. cmp ( name2) ) ;
1727
- struct NotableTraitsMap ( Vec < ( String , String ) > ) ;
1728
- impl Serialize for NotableTraitsMap {
1729
- fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
1730
- where
1731
- S : Serializer ,
1732
- {
1733
- let mut map = serializer. serialize_map ( Some ( self . 0 . len ( ) ) ) ?;
1734
- for item in & self . 0 {
1735
- map. serialize_entry ( & item. 0 , & item. 1 ) ?;
1736
- }
1737
- map. end ( )
1738
- }
1739
- }
1740
- serde_json:: to_string ( & NotableTraitsMap ( mp) )
1741
- . expect ( "serialize (string, string) -> json object cannot fail" )
1724
+ let mut mp = tys. map ( |ty| notable_traits_decl ( ty, cx) ) . collect :: < IndexMap < _ , _ > > ( ) ;
1725
+ mp. sort_unstable_keys ( ) ;
1726
+ serde_json:: to_string ( & mp) . expect ( "serialize (string, string) -> json object cannot fail" )
1742
1727
}
1743
1728
1744
1729
#[ derive( Clone , Copy , Debug ) ]
0 commit comments