@@ -1474,7 +1474,7 @@ impl GenericParamDefKind {
14741474 }
14751475 }
14761476
1477- pub fn get_type ( & self , cx : & DocContext < ' _ , ' _ , ' _ > ) -> Option < Type > {
1477+ pub fn get_type ( & self , cx : & DocContext < ' _ > ) -> Option < Type > {
14781478 match * self {
14791479 GenericParamDefKind :: Type { did, .. } => {
14801480 rustc_typeck:: checked_type_of ( cx. tcx , did, false ) . map ( |t| t. clean ( cx) )
@@ -1505,7 +1505,7 @@ impl GenericParamDef {
15051505 self . kind . is_type ( )
15061506 }
15071507
1508- pub fn get_type ( & self , cx : & DocContext < ' _ , ' _ , ' _ > ) -> Option < Type > {
1508+ pub fn get_type ( & self , cx : & DocContext < ' _ > ) -> Option < Type > {
15091509 self . kind . get_type ( cx)
15101510 }
15111511
@@ -1750,12 +1750,16 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17501750 }
17511751}
17521752
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).
17541758fn get_real_types (
17551759 generics : & Generics ,
17561760 arg : & Type ,
1757- cx : & DocContext < ' _ , ' _ , ' _ > ,
1758- ) -> Vec < Type > {
1761+ cx : & DocContext < ' _ > ,
1762+ ) -> FxHashSet < Type > {
17591763 let arg_s = arg. to_string ( ) ;
17601764 let mut res = Vec :: new ( ) ;
17611765 if arg. is_full_generic ( ) {
@@ -1776,7 +1780,7 @@ fn get_real_types(
17761780 if let Some ( ty) = x. get_type ( cx) {
17771781 let mut adds = get_real_types ( generics, & ty, cx) ;
17781782 if !adds. is_empty ( ) {
1779- res. append ( & mut adds) ;
1783+ res. extend ( adds) ;
17801784 } else if !ty. is_full_generic ( ) {
17811785 res. push ( ty) ;
17821786 }
@@ -1794,7 +1798,7 @@ fn get_real_types(
17941798 if let Some ( ty) = bound. get_trait_type ( ) {
17951799 let mut adds = get_real_types ( generics, & ty, cx) ;
17961800 if !adds. is_empty ( ) {
1797- res. append ( & mut adds) ;
1801+ res. extend ( adds) ;
17981802 } else if !ty. is_full_generic ( ) {
17991803 res. push ( ty. clone ( ) ) ;
18001804 }
@@ -1808,7 +1812,7 @@ fn get_real_types(
18081812 if gen. is_full_generic ( ) {
18091813 let mut adds = get_real_types ( generics, gen, cx) ;
18101814 if !adds. is_empty ( ) {
1811- res. append ( & mut adds) ;
1815+ res. extend ( adds) ;
18121816 }
18131817 } else {
18141818 res. push ( gen. clone ( ) ) ;
@@ -1819,10 +1823,14 @@ fn get_real_types(
18191823 res
18201824}
18211825
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]`.
18221830pub fn get_all_types (
18231831 generics : & Generics ,
18241832 decl : & FnDecl ,
1825- cx : & DocContext < ' _ , ' _ , ' _ > ,
1833+ cx : & DocContext < ' _ > ,
18261834) -> ( Vec < Type > , Vec < Type > ) {
18271835 let mut all_types = Vec :: new ( ) ;
18281836 for arg in decl. inputs . values . iter ( ) {
@@ -1831,7 +1839,7 @@ pub fn get_all_types(
18311839 }
18321840 let mut args = get_real_types ( generics, & arg. type_ , cx) ;
18331841 if !args. is_empty ( ) {
1834- all_types. append ( & mut args) ;
1842+ all_types. extend ( args) ;
18351843 } else {
18361844 all_types. push ( arg. type_ . clone ( ) ) ;
18371845 }
0 commit comments