@@ -1761,7 +1761,7 @@ fn get_real_types(
1761
1761
cx : & DocContext < ' _ > ,
1762
1762
) -> FxHashSet < Type > {
1763
1763
let arg_s = arg. to_string ( ) ;
1764
- let mut res = Vec :: new ( ) ;
1764
+ let mut res = FxHashSet :: default ( ) ;
1765
1765
if arg. is_full_generic ( ) {
1766
1766
if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| {
1767
1767
match g {
@@ -1778,11 +1778,11 @@ fn get_real_types(
1778
1778
continue
1779
1779
}
1780
1780
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) ;
1782
1782
if !adds. is_empty ( ) {
1783
1783
res. extend ( adds) ;
1784
1784
} else if !ty. is_full_generic ( ) {
1785
- res. push ( ty) ;
1785
+ res. insert ( ty) ;
1786
1786
}
1787
1787
}
1788
1788
}
@@ -1796,26 +1796,26 @@ fn get_real_types(
1796
1796
} ) {
1797
1797
for bound in bound. get_bounds ( ) . unwrap_or_else ( || & [ ] ) {
1798
1798
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) ;
1800
1800
if !adds. is_empty ( ) {
1801
1801
res. extend ( adds) ;
1802
1802
} else if !ty. is_full_generic ( ) {
1803
- res. push ( ty. clone ( ) ) ;
1803
+ res. insert ( ty. clone ( ) ) ;
1804
1804
}
1805
1805
}
1806
1806
}
1807
1807
}
1808
1808
} else {
1809
- res. push ( arg. clone ( ) ) ;
1809
+ res. insert ( arg. clone ( ) ) ;
1810
1810
if let Some ( gens) = arg. generics ( ) {
1811
1811
for gen in gens. iter ( ) {
1812
1812
if gen. is_full_generic ( ) {
1813
- let mut adds = get_real_types ( generics, gen, cx) ;
1813
+ let adds = get_real_types ( generics, gen, cx) ;
1814
1814
if !adds. is_empty ( ) {
1815
1815
res. extend ( adds) ;
1816
1816
}
1817
1817
} else {
1818
- res. push ( gen. clone ( ) ) ;
1818
+ res. insert ( gen. clone ( ) ) ;
1819
1819
}
1820
1820
}
1821
1821
}
@@ -1832,36 +1832,30 @@ pub fn get_all_types(
1832
1832
decl : & FnDecl ,
1833
1833
cx : & DocContext < ' _ > ,
1834
1834
) -> ( Vec < Type > , Vec < Type > ) {
1835
- let mut all_types = Vec :: new ( ) ;
1835
+ let mut all_types = FxHashSet :: default ( ) ;
1836
1836
for arg in decl. inputs . values . iter ( ) {
1837
1837
if arg. type_ . is_self_type ( ) {
1838
1838
continue ;
1839
1839
}
1840
- let mut args = get_real_types ( generics, & arg. type_ , cx) ;
1840
+ let args = get_real_types ( generics, & arg. type_ , cx) ;
1841
1841
if !args. is_empty ( ) {
1842
1842
all_types. extend ( args) ;
1843
1843
} else {
1844
- all_types. push ( arg. type_ . clone ( ) ) ;
1844
+ all_types. insert ( arg. type_ . clone ( ) ) ;
1845
1845
}
1846
1846
}
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 ( ) ;
1850
1847
1851
- let mut ret_types = match decl. output {
1848
+ let ret_types = match decl. output {
1852
1849
FunctionRetTy :: Return ( ref return_type) => {
1853
1850
let mut ret = get_real_types ( generics, & return_type, cx) ;
1854
1851
if ret. is_empty ( ) {
1855
- ret. push ( return_type. clone ( ) ) ;
1852
+ ret. insert ( return_type. clone ( ) ) ;
1856
1853
}
1857
- ret
1854
+ ret. into_iter ( ) . collect ( )
1858
1855
}
1859
1856
_ => Vec :: new ( ) ,
1860
1857
} ;
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)
1865
1859
}
1866
1860
1867
1861
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
0 commit comments