@@ -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 } ;
@@ -58,8 +59,6 @@ use rustc_middle::ty::print::PrintTraitRefExt;
5859use rustc_middle:: ty:: { self , TyCtxt } ;
5960use rustc_span:: symbol:: { Symbol , sym} ;
6061use rustc_span:: { BytePos , DUMMY_SP , FileName , RealFileName } ;
61- use serde:: ser:: SerializeMap ;
62- use serde:: { Serialize , Serializer } ;
6362use tracing:: { debug, info} ;
6463
6564pub ( crate ) use self :: context:: * ;
@@ -1757,23 +1756,9 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
17571756}
17581757
17591758fn notable_traits_json < ' a > ( tys : impl Iterator < Item = & ' a clean:: Type > , cx : & Context < ' _ > ) -> String {
1760- let mut mp: Vec < ( String , String ) > = tys. map ( |ty| notable_traits_decl ( ty, cx) ) . collect ( ) ;
1761- mp. sort_by ( |( name1, _html1) , ( name2, _html2) | name1. cmp ( name2) ) ;
1762- struct NotableTraitsMap ( Vec < ( String , String ) > ) ;
1763- impl Serialize for NotableTraitsMap {
1764- fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
1765- where
1766- S : Serializer ,
1767- {
1768- let mut map = serializer. serialize_map ( Some ( self . 0 . len ( ) ) ) ?;
1769- for item in & self . 0 {
1770- map. serialize_entry ( & item. 0 , & item. 1 ) ?;
1771- }
1772- map. end ( )
1773- }
1774- }
1775- serde_json:: to_string ( & NotableTraitsMap ( mp) )
1776- . expect ( "serialize (string, string) -> json object cannot fail" )
1759+ let mut mp = tys. map ( |ty| notable_traits_decl ( ty, cx) ) . collect :: < IndexMap < _ , _ > > ( ) ;
1760+ mp. sort_unstable_keys ( ) ;
1761+ serde_json:: to_string ( & mp) . expect ( "serialize (string, string) -> json object cannot fail" )
17771762}
17781763
17791764#[ derive( Clone , Copy , Debug ) ]
0 commit comments