@@ -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 } ;
@@ -58,8 +59,6 @@ use rustc_middle::ty::print::PrintTraitRefExt;
58
59
use rustc_middle:: ty:: { self , TyCtxt } ;
59
60
use rustc_span:: symbol:: { Symbol , sym} ;
60
61
use rustc_span:: { BytePos , DUMMY_SP , FileName , RealFileName } ;
61
- use serde:: ser:: SerializeMap ;
62
- use serde:: { Serialize , Serializer } ;
63
62
use tracing:: { debug, info} ;
64
63
65
64
pub ( crate ) use self :: context:: * ;
@@ -1757,23 +1756,9 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
1757
1756
}
1758
1757
1759
1758
fn 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" )
1777
1762
}
1778
1763
1779
1764
#[ derive( Clone , Copy , Debug ) ]
0 commit comments