@@ -1751,7 +1751,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
1751
1751
}
1752
1752
1753
1753
// The point is to replace bounds with types.
1754
- pub fn get_real_types (
1754
+ fn get_real_types (
1755
1755
generics : & Generics ,
1756
1756
arg : & Type ,
1757
1757
cx : & DocContext < ' _ , ' _ , ' _ > ,
@@ -1822,7 +1822,7 @@ pub fn get_all_types(
1822
1822
generics : & Generics ,
1823
1823
decl : & FnDecl ,
1824
1824
cx : & DocContext < ' _ , ' _ , ' _ > ,
1825
- ) -> Vec < Type > {
1825
+ ) -> ( Vec < Type > , Vec < Type > ) {
1826
1826
let mut all_types = Vec :: new ( ) ;
1827
1827
for arg in decl. inputs . values . iter ( ) {
1828
1828
if arg. type_ . is_self_type ( ) {
@@ -1837,7 +1837,23 @@ pub fn get_all_types(
1837
1837
// FIXME: use a HashSet instead?
1838
1838
all_types. sort_unstable_by ( |a, b| a. to_string ( ) . partial_cmp ( & b. to_string ( ) ) . unwrap ( ) ) ;
1839
1839
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)
1841
1857
}
1842
1858
1843
1859
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -1847,6 +1863,7 @@ pub struct Method {
1847
1863
pub header : hir:: FnHeader ,
1848
1864
pub defaultness : Option < hir:: Defaultness > ,
1849
1865
pub all_types : Vec < Type > ,
1866
+ pub ret_types : Vec < Type > ,
1850
1867
}
1851
1868
1852
1869
impl < ' 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,
1855
1872
let ( generics, decl) = enter_impl_trait ( cx, || {
1856
1873
( self . 1 . clean ( cx) , ( & * self . 0 . decl , self . 2 ) . clean ( cx) )
1857
1874
} ) ;
1858
- let all_types = get_all_types ( & generics, & decl, cx) ;
1875
+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
1859
1876
Method {
1860
1877
decl,
1861
1878
generics,
1862
1879
header : self . 0 . header ,
1863
1880
defaultness : self . 3 ,
1864
1881
all_types,
1882
+ ret_types,
1865
1883
}
1866
1884
}
1867
1885
}
@@ -1872,6 +1890,7 @@ pub struct TyMethod {
1872
1890
pub decl : FnDecl ,
1873
1891
pub generics : Generics ,
1874
1892
pub all_types : Vec < Type > ,
1893
+ pub ret_types : Vec < Type > ,
1875
1894
}
1876
1895
1877
1896
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -1880,6 +1899,7 @@ pub struct Function {
1880
1899
pub generics : Generics ,
1881
1900
pub header : hir:: FnHeader ,
1882
1901
pub all_types : Vec < Type > ,
1902
+ pub ret_types : Vec < Type > ,
1883
1903
}
1884
1904
1885
1905
impl Clean < Item > for doctree:: Function {
@@ -1894,7 +1914,7 @@ impl Clean<Item> for doctree::Function {
1894
1914
} else {
1895
1915
hir:: Constness :: NotConst
1896
1916
} ;
1897
- let all_types = get_all_types ( & generics, & decl, cx) ;
1917
+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
1898
1918
Item {
1899
1919
name : Some ( self . name . clean ( cx) ) ,
1900
1920
attrs : self . attrs . clean ( cx) ,
@@ -1908,6 +1928,7 @@ impl Clean<Item> for doctree::Function {
1908
1928
generics,
1909
1929
header : hir:: FnHeader { constness, ..self . header } ,
1910
1930
all_types,
1931
+ ret_types,
1911
1932
} ) ,
1912
1933
}
1913
1934
}
@@ -2177,12 +2198,13 @@ impl Clean<Item> for hir::TraitItem {
2177
2198
let ( generics, decl) = enter_impl_trait ( cx, || {
2178
2199
( self . generics . clean ( cx) , ( & * sig. decl , & names[ ..] ) . clean ( cx) )
2179
2200
} ) ;
2180
- let all_types = get_all_types ( & generics, & decl, cx) ;
2201
+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
2181
2202
TyMethodItem ( TyMethod {
2182
2203
header : sig. header ,
2183
2204
decl,
2184
2205
generics,
2185
2206
all_types,
2207
+ ret_types,
2186
2208
} )
2187
2209
}
2188
2210
hir:: TraitItemKind :: Type ( ref bounds, ref default) => {
@@ -2280,7 +2302,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
2280
2302
ty:: ImplContainer ( _) => true ,
2281
2303
ty:: TraitContainer ( _) => self . defaultness . has_value ( )
2282
2304
} ;
2283
- let all_types = get_all_types ( & generics, & decl, cx) ;
2305
+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
2284
2306
if provided {
2285
2307
let constness = if cx. tcx . is_min_const_fn ( self . def_id ) {
2286
2308
hir:: Constness :: Const
@@ -2298,6 +2320,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
2298
2320
} ,
2299
2321
defaultness : Some ( self . defaultness ) ,
2300
2322
all_types,
2323
+ ret_types,
2301
2324
} )
2302
2325
} else {
2303
2326
TyMethodItem ( TyMethod {
@@ -2310,6 +2333,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
2310
2333
asyncness : hir:: IsAsync :: NotAsync ,
2311
2334
} ,
2312
2335
all_types,
2336
+ ret_types,
2313
2337
} )
2314
2338
}
2315
2339
}
@@ -3976,7 +4000,7 @@ impl Clean<Item> for hir::ForeignItem {
3976
4000
let ( generics, decl) = enter_impl_trait ( cx, || {
3977
4001
( generics. clean ( cx) , ( & * * decl, & names[ ..] ) . clean ( cx) )
3978
4002
} ) ;
3979
- let all_types = get_all_types ( & generics, & decl, cx) ;
4003
+ let ( all_types, ret_types ) = get_all_types ( & generics, & decl, cx) ;
3980
4004
ForeignFunctionItem ( Function {
3981
4005
decl,
3982
4006
generics,
@@ -3987,6 +4011,7 @@ impl Clean<Item> for hir::ForeignItem {
3987
4011
asyncness : hir:: IsAsync :: NotAsync ,
3988
4012
} ,
3989
4013
all_types,
4014
+ ret_types,
3990
4015
} )
3991
4016
}
3992
4017
hir:: ForeignItemKind :: Static ( ref ty, mutbl) => {
0 commit comments