@@ -1761,7 +1761,7 @@ fn get_real_types(
17611761 cx : & DocContext < ' _ > ,
17621762) -> FxHashSet < Type > {
17631763 let arg_s = arg. to_string ( ) ;
1764- let mut res = Vec :: new ( ) ;
1764+ let mut res = FxHashSet :: default ( ) ;
17651765 if arg. is_full_generic ( ) {
17661766 if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| {
17671767 match g {
@@ -1778,11 +1778,11 @@ fn get_real_types(
17781778 continue
17791779 }
17801780 if let Some ( ty) = x. get_type ( cx) {
1781- let mut adds = get_real_types ( generics, & ty, cx) ;
1781+ let adds = get_real_types ( generics, & ty, cx) ;
17821782 if !adds. is_empty ( ) {
17831783 res. extend ( adds) ;
17841784 } else if !ty. is_full_generic ( ) {
1785- res. push ( ty) ;
1785+ res. insert ( ty) ;
17861786 }
17871787 }
17881788 }
@@ -1796,26 +1796,26 @@ fn get_real_types(
17961796 } ) {
17971797 for bound in bound. get_bounds ( ) . unwrap_or_else ( || & [ ] ) {
17981798 if let Some ( ty) = bound. get_trait_type ( ) {
1799- let mut adds = get_real_types ( generics, & ty, cx) ;
1799+ let adds = get_real_types ( generics, & ty, cx) ;
18001800 if !adds. is_empty ( ) {
18011801 res. extend ( adds) ;
18021802 } else if !ty. is_full_generic ( ) {
1803- res. push ( ty. clone ( ) ) ;
1803+ res. insert ( ty. clone ( ) ) ;
18041804 }
18051805 }
18061806 }
18071807 }
18081808 } else {
1809- res. push ( arg. clone ( ) ) ;
1809+ res. insert ( arg. clone ( ) ) ;
18101810 if let Some ( gens) = arg. generics ( ) {
18111811 for gen in gens. iter ( ) {
18121812 if gen. is_full_generic ( ) {
1813- let mut adds = get_real_types ( generics, gen, cx) ;
1813+ let adds = get_real_types ( generics, gen, cx) ;
18141814 if !adds. is_empty ( ) {
18151815 res. extend ( adds) ;
18161816 }
18171817 } else {
1818- res. push ( gen. clone ( ) ) ;
1818+ res. insert ( gen. clone ( ) ) ;
18191819 }
18201820 }
18211821 }
@@ -1832,36 +1832,30 @@ pub fn get_all_types(
18321832 decl : & FnDecl ,
18331833 cx : & DocContext < ' _ > ,
18341834) -> ( Vec < Type > , Vec < Type > ) {
1835- let mut all_types = Vec :: new ( ) ;
1835+ let mut all_types = FxHashSet :: default ( ) ;
18361836 for arg in decl. inputs . values . iter ( ) {
18371837 if arg. type_ . is_self_type ( ) {
18381838 continue ;
18391839 }
1840- let mut args = get_real_types ( generics, & arg. type_ , cx) ;
1840+ let args = get_real_types ( generics, & arg. type_ , cx) ;
18411841 if !args. is_empty ( ) {
18421842 all_types. extend ( args) ;
18431843 } else {
1844- all_types. push ( arg. type_ . clone ( ) ) ;
1844+ all_types. insert ( arg. type_ . clone ( ) ) ;
18451845 }
18461846 }
1847- // FIXME: use a HashSet instead?
1848- all_types. sort_unstable_by ( |a, b| a. to_string ( ) . partial_cmp ( & b. to_string ( ) ) . unwrap ( ) ) ;
1849- all_types. dedup ( ) ;
18501847
1851- let mut ret_types = match decl. output {
1848+ let ret_types = match decl. output {
18521849 FunctionRetTy :: Return ( ref return_type) => {
18531850 let mut ret = get_real_types ( generics, & return_type, cx) ;
18541851 if ret. is_empty ( ) {
1855- ret. push ( return_type. clone ( ) ) ;
1852+ ret. insert ( return_type. clone ( ) ) ;
18561853 }
1857- ret
1854+ ret. into_iter ( ) . collect ( )
18581855 }
18591856 _ => Vec :: new ( ) ,
18601857 } ;
1861- // FIXME: use a HashSet instead?
1862- ret_types. sort_unstable_by ( |a, b| a. to_string ( ) . partial_cmp ( & b. to_string ( ) ) . unwrap ( ) ) ;
1863- ret_types. dedup ( ) ;
1864- ( all_types, ret_types)
1858+ ( all_types. into_iter ( ) . collect ( ) , ret_types)
18651859}
18661860
18671861#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
0 commit comments