@@ -1474,7 +1474,7 @@ impl GenericParamDefKind {
1474
1474
}
1475
1475
}
1476
1476
1477
- pub fn get_type ( & self , cx : & DocContext < ' _ , ' _ , ' _ > ) -> Option < Type > {
1477
+ pub fn get_type ( & self , cx : & DocContext < ' _ > ) -> Option < Type > {
1478
1478
match * self {
1479
1479
GenericParamDefKind :: Type { did, .. } => {
1480
1480
rustc_typeck:: checked_type_of ( cx. tcx , did, false ) . map ( |t| t. clean ( cx) )
@@ -1505,7 +1505,7 @@ impl GenericParamDef {
1505
1505
self . kind . is_type ( )
1506
1506
}
1507
1507
1508
- pub fn get_type ( & self , cx : & DocContext < ' _ , ' _ , ' _ > ) -> Option < Type > {
1508
+ pub fn get_type ( & self , cx : & DocContext < ' _ > ) -> Option < Type > {
1509
1509
self . kind . get_type ( cx)
1510
1510
}
1511
1511
@@ -1750,12 +1750,16 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
1750
1750
}
1751
1751
}
1752
1752
1753
- // The point is to replace bounds with types.
1753
+ /// The point of this function is to replace bounds with types.
1754
+ ///
1755
+ /// i.e. `[T, U]` when you have the following bounds: `T: Display, U: Option<T>` will return
1756
+ /// `[Display, Option]` (we just returns the list of the types, we don't care about the
1757
+ /// wrapped types in here).
1754
1758
fn get_real_types (
1755
1759
generics : & Generics ,
1756
1760
arg : & Type ,
1757
- cx : & DocContext < ' _ , ' _ , ' _ > ,
1758
- ) -> Vec < Type > {
1761
+ cx : & DocContext < ' _ > ,
1762
+ ) -> FxHashSet < Type > {
1759
1763
let arg_s = arg. to_string ( ) ;
1760
1764
let mut res = Vec :: new ( ) ;
1761
1765
if arg. is_full_generic ( ) {
@@ -1776,7 +1780,7 @@ fn get_real_types(
1776
1780
if let Some ( ty) = x. get_type ( cx) {
1777
1781
let mut adds = get_real_types ( generics, & ty, cx) ;
1778
1782
if !adds. is_empty ( ) {
1779
- res. append ( & mut adds) ;
1783
+ res. extend ( adds) ;
1780
1784
} else if !ty. is_full_generic ( ) {
1781
1785
res. push ( ty) ;
1782
1786
}
@@ -1794,7 +1798,7 @@ fn get_real_types(
1794
1798
if let Some ( ty) = bound. get_trait_type ( ) {
1795
1799
let mut adds = get_real_types ( generics, & ty, cx) ;
1796
1800
if !adds. is_empty ( ) {
1797
- res. append ( & mut adds) ;
1801
+ res. extend ( adds) ;
1798
1802
} else if !ty. is_full_generic ( ) {
1799
1803
res. push ( ty. clone ( ) ) ;
1800
1804
}
@@ -1808,7 +1812,7 @@ fn get_real_types(
1808
1812
if gen. is_full_generic ( ) {
1809
1813
let mut adds = get_real_types ( generics, gen, cx) ;
1810
1814
if !adds. is_empty ( ) {
1811
- res. append ( & mut adds) ;
1815
+ res. extend ( adds) ;
1812
1816
}
1813
1817
} else {
1814
1818
res. push ( gen. clone ( ) ) ;
@@ -1819,10 +1823,14 @@ fn get_real_types(
1819
1823
res
1820
1824
}
1821
1825
1826
+ /// Return the full list of types when bounds have been resolved.
1827
+ ///
1828
+ /// i.e. `fn foo<A: Display, B: Option<A>>(x: u32, y: B)` will return
1829
+ /// `[u32, Display, Option]`.
1822
1830
pub fn get_all_types (
1823
1831
generics : & Generics ,
1824
1832
decl : & FnDecl ,
1825
- cx : & DocContext < ' _ , ' _ , ' _ > ,
1833
+ cx : & DocContext < ' _ > ,
1826
1834
) -> ( Vec < Type > , Vec < Type > ) {
1827
1835
let mut all_types = Vec :: new ( ) ;
1828
1836
for arg in decl. inputs . values . iter ( ) {
@@ -1831,7 +1839,7 @@ pub fn get_all_types(
1831
1839
}
1832
1840
let mut args = get_real_types ( generics, & arg. type_ , cx) ;
1833
1841
if !args. is_empty ( ) {
1834
- all_types. append ( & mut args) ;
1842
+ all_types. extend ( args) ;
1835
1843
} else {
1836
1844
all_types. push ( arg. type_ . clone ( ) ) ;
1837
1845
}
0 commit comments