@@ -1751,7 +1751,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17511751}
17521752
17531753// The point is to replace bounds with types.
1754- pub fn get_real_types (
1754+ fn get_real_types (
17551755 generics : & Generics ,
17561756 arg : & Type ,
17571757 cx : & DocContext < ' _ , ' _ , ' _ > ,
@@ -1822,7 +1822,7 @@ pub fn get_all_types(
18221822 generics : & Generics ,
18231823 decl : & FnDecl ,
18241824 cx : & DocContext < ' _ , ' _ , ' _ > ,
1825- ) -> Vec < Type > {
1825+ ) -> ( Vec < Type > , Vec < Type > ) {
18261826 let mut all_types = Vec :: new ( ) ;
18271827 for arg in decl. inputs . values . iter ( ) {
18281828 if arg. type_ . is_self_type ( ) {
@@ -1837,7 +1837,23 @@ pub fn get_all_types(
18371837 // FIXME: use a HashSet instead?
18381838 all_types. sort_unstable_by ( |a, b| a. to_string ( ) . partial_cmp ( & b. to_string ( ) ) . unwrap ( ) ) ;
18391839 all_types. dedup ( ) ;
1840- all_types
1840+
1841+ let mut ret_types = match decl. output {
1842+ FunctionRetTy :: Return ( ref return_type) => {
1843+ let mut ret = Vec :: new ( ) ;
1844+ if let Some ( mut args) = get_real_types ( generics, & return_type, cx) {
1845+ ret. append ( & mut args) ;
1846+ } else {
1847+ ret. push ( return_type. clone ( ) ) ;
1848+ }
1849+ ret
1850+ }
1851+ _ => Vec :: new ( ) ,
1852+ } ;
1853+ // FIXME: use a HashSet instead?
1854+ ret_types. sort_unstable_by ( |a, b| a. to_string ( ) . partial_cmp ( & b. to_string ( ) ) . unwrap ( ) ) ;
1855+ ret_types. dedup ( ) ;
1856+ ( all_types, ret_types)
18411857}
18421858
18431859#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -1847,6 +1863,7 @@ pub struct Method {
18471863 pub header : hir:: FnHeader ,
18481864 pub defaultness : Option < hir:: Defaultness > ,
18491865 pub all_types : Vec < Type > ,
1866+ pub ret_types : Vec < Type > ,
18501867}
18511868
18521869impl < ' a > Clean < Method > for ( & ' a hir:: MethodSig , & ' a hir:: Generics , hir:: BodyId ,
@@ -1855,13 +1872,14 @@ impl<'a> Clean<Method> for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId,
18551872 let ( generics, decl) = enter_impl_trait ( cx, || {
18561873 ( self . 1 . clean ( cx) , ( & * self . 0 . decl , self . 2 ) . clean ( cx) )
18571874 } ) ;
1858- let all_types = get_all_types ( & generics, & decl, cx) ;
1875+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
18591876 Method {
18601877 decl,
18611878 generics,
18621879 header : self . 0 . header ,
18631880 defaultness : self . 3 ,
18641881 all_types,
1882+ ret_types,
18651883 }
18661884 }
18671885}
@@ -1872,6 +1890,7 @@ pub struct TyMethod {
18721890 pub decl : FnDecl ,
18731891 pub generics : Generics ,
18741892 pub all_types : Vec < Type > ,
1893+ pub ret_types : Vec < Type > ,
18751894}
18761895
18771896#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -1880,6 +1899,7 @@ pub struct Function {
18801899 pub generics : Generics ,
18811900 pub header : hir:: FnHeader ,
18821901 pub all_types : Vec < Type > ,
1902+ pub ret_types : Vec < Type > ,
18831903}
18841904
18851905impl Clean < Item > for doctree:: Function {
@@ -1894,7 +1914,7 @@ impl Clean<Item> for doctree::Function {
18941914 } else {
18951915 hir:: Constness :: NotConst
18961916 } ;
1897- let all_types = get_all_types ( & generics, & decl, cx) ;
1917+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
18981918 Item {
18991919 name : Some ( self . name . clean ( cx) ) ,
19001920 attrs : self . attrs . clean ( cx) ,
@@ -1908,6 +1928,7 @@ impl Clean<Item> for doctree::Function {
19081928 generics,
19091929 header : hir:: FnHeader { constness, ..self . header } ,
19101930 all_types,
1931+ ret_types,
19111932 } ) ,
19121933 }
19131934 }
@@ -2177,12 +2198,13 @@ impl Clean<Item> for hir::TraitItem {
21772198 let ( generics, decl) = enter_impl_trait ( cx, || {
21782199 ( self . generics . clean ( cx) , ( & * sig. decl , & names[ ..] ) . clean ( cx) )
21792200 } ) ;
2180- let all_types = get_all_types ( & generics, & decl, cx) ;
2201+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
21812202 TyMethodItem ( TyMethod {
21822203 header : sig. header ,
21832204 decl,
21842205 generics,
21852206 all_types,
2207+ ret_types,
21862208 } )
21872209 }
21882210 hir:: TraitItemKind :: Type ( ref bounds, ref default) => {
@@ -2280,7 +2302,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
22802302 ty:: ImplContainer ( _) => true ,
22812303 ty:: TraitContainer ( _) => self . defaultness . has_value ( )
22822304 } ;
2283- let all_types = get_all_types ( & generics, & decl, cx) ;
2305+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
22842306 if provided {
22852307 let constness = if cx. tcx . is_min_const_fn ( self . def_id ) {
22862308 hir:: Constness :: Const
@@ -2298,6 +2320,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
22982320 } ,
22992321 defaultness : Some ( self . defaultness ) ,
23002322 all_types,
2323+ ret_types,
23012324 } )
23022325 } else {
23032326 TyMethodItem ( TyMethod {
@@ -2310,6 +2333,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
23102333 asyncness : hir:: IsAsync :: NotAsync ,
23112334 } ,
23122335 all_types,
2336+ ret_types,
23132337 } )
23142338 }
23152339 }
@@ -3976,7 +4000,7 @@ impl Clean<Item> for hir::ForeignItem {
39764000 let ( generics, decl) = enter_impl_trait ( cx, || {
39774001 ( generics. clean ( cx) , ( & * * decl, & names[ ..] ) . clean ( cx) )
39784002 } ) ;
3979- let all_types = get_all_types ( & generics, & decl, cx) ;
4003+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
39804004 ForeignFunctionItem ( Function {
39814005 decl,
39824006 generics,
@@ -3987,6 +4011,7 @@ impl Clean<Item> for hir::ForeignItem {
39874011 asyncness : hir:: IsAsync :: NotAsync ,
39884012 } ,
39894013 all_types,
4014+ ret_types,
39904015 } )
39914016 }
39924017 hir:: ForeignItemKind :: Static ( ref ty, mutbl) => {
0 commit comments