@@ -48,6 +48,7 @@ use std::path::PathBuf;
4848use std:: { fs, str} ;
4949
5050use askama:: Template ;
51+ use indexmap:: IndexMap ;
5152use itertools:: Either ;
5253use rustc_ast:: join_path_syms;
5354use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
@@ -60,8 +61,6 @@ use rustc_middle::ty::print::PrintTraitRefExt;
6061use rustc_middle:: ty:: { self , TyCtxt } ;
6162use rustc_span:: symbol:: { Symbol , sym} ;
6263use rustc_span:: { BytePos , DUMMY_SP , FileName , RealFileName } ;
63- use serde:: ser:: SerializeMap ;
64- use serde:: { Serialize , Serializer } ;
6564use tracing:: { debug, info} ;
6665
6766pub ( crate ) use self :: context:: * ;
@@ -1722,23 +1721,9 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
17221721}
17231722
17241723fn 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" )
17421727}
17431728
17441729#[ derive( Clone , Copy , Debug ) ]
0 commit comments