@@ -1755,55 +1755,59 @@ fn get_real_types(
1755
1755
generics : & Generics ,
1756
1756
arg : & Type ,
1757
1757
cx : & DocContext < ' _ , ' _ , ' _ > ,
1758
- ) -> Option < Vec < Type > > {
1758
+ ) -> Vec < Type > {
1759
+ let arg_s = arg. to_string ( ) ;
1759
1760
let mut res = Vec :: new ( ) ;
1760
- if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| {
1761
- match g {
1762
- & WherePredicate :: BoundPredicate { ref ty, .. } => ty. def_id ( ) == arg. def_id ( ) ,
1763
- _ => false ,
1764
- }
1765
- } ) {
1766
- let bounds = where_pred. get_bounds ( ) . unwrap_or_else ( || & [ ] ) ;
1767
- for bound in bounds. iter ( ) {
1768
- match * bound {
1769
- GenericBound :: TraitBound ( ref poly_trait, _) => {
1770
- for x in poly_trait. generic_params . iter ( ) {
1771
- if !x. is_type ( ) {
1772
- continue
1773
- }
1774
- if let Some ( ty) = x. get_type ( cx) {
1775
- if let Some ( mut adds) = get_real_types ( generics, & ty, cx) {
1776
- res. append ( & mut adds) ;
1777
- } else if !ty. is_full_generic ( ) {
1778
- res. push ( ty) ;
1761
+ if arg. is_full_generic ( ) {
1762
+ if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| {
1763
+ match g {
1764
+ & WherePredicate :: BoundPredicate { ref ty, .. } => ty. def_id ( ) == arg. def_id ( ) ,
1765
+ _ => false ,
1766
+ }
1767
+ } ) {
1768
+ let bounds = where_pred. get_bounds ( ) . unwrap_or_else ( || & [ ] ) ;
1769
+ for bound in bounds. iter ( ) {
1770
+ match * bound {
1771
+ GenericBound :: TraitBound ( ref poly_trait, _) => {
1772
+ for x in poly_trait. generic_params . iter ( ) {
1773
+ if !x. is_type ( ) {
1774
+ continue
1775
+ }
1776
+ if let Some ( ty) = x. get_type ( cx) {
1777
+ let mut adds = get_real_types ( generics, & ty, cx) ;
1778
+ if !adds. is_empty ( ) {
1779
+ res. append ( & mut adds) ;
1780
+ } else if !ty. is_full_generic ( ) {
1781
+ res. push ( ty) ;
1782
+ }
1779
1783
}
1780
1784
}
1781
1785
}
1786
+ _ => { }
1782
1787
}
1783
- _ => { }
1784
1788
}
1785
1789
}
1786
- } else {
1787
- let arg_s = arg. to_string ( ) ;
1788
1790
if let Some ( bound) = generics. params . iter ( ) . find ( |g| {
1789
1791
g. is_type ( ) && g. name == arg_s
1790
1792
} ) {
1791
1793
for bound in bound. get_bounds ( ) . unwrap_or_else ( || & [ ] ) {
1792
1794
if let Some ( ty) = bound. get_trait_type ( ) {
1793
- if let Some ( mut adds) = get_real_types ( generics, & ty, cx) {
1795
+ let mut adds = get_real_types ( generics, & ty, cx) ;
1796
+ if !adds. is_empty ( ) {
1794
1797
res. append ( & mut adds) ;
1795
- } else {
1796
- if !ty. is_full_generic ( ) {
1797
- res. push ( ty. clone ( ) ) ;
1798
- }
1798
+ } else if !ty. is_full_generic ( ) {
1799
+ res. push ( ty. clone ( ) ) ;
1799
1800
}
1800
1801
}
1801
1802
}
1802
- } else if let Some ( gens) = arg. generics ( ) {
1803
- res. push ( arg. clone ( ) ) ;
1803
+ }
1804
+ } else {
1805
+ res. push ( arg. clone ( ) ) ;
1806
+ if let Some ( gens) = arg. generics ( ) {
1804
1807
for gen in gens. iter ( ) {
1805
1808
if gen. is_full_generic ( ) {
1806
- if let Some ( mut adds) = get_real_types ( generics, gen, cx) {
1809
+ let mut adds = get_real_types ( generics, gen, cx) ;
1810
+ if !adds. is_empty ( ) {
1807
1811
res. append ( & mut adds) ;
1808
1812
}
1809
1813
} else {
@@ -1812,10 +1816,7 @@ fn get_real_types(
1812
1816
}
1813
1817
}
1814
1818
}
1815
- if res. is_empty ( ) && !arg. is_full_generic ( ) {
1816
- res. push ( arg. clone ( ) ) ;
1817
- }
1818
- Some ( res)
1819
+ res
1819
1820
}
1820
1821
1821
1822
pub fn get_all_types (
@@ -1828,7 +1829,8 @@ pub fn get_all_types(
1828
1829
if arg. type_ . is_self_type ( ) {
1829
1830
continue ;
1830
1831
}
1831
- if let Some ( mut args) = get_real_types ( generics, & arg. type_ , cx) {
1832
+ let mut args = get_real_types ( generics, & arg. type_ , cx) ;
1833
+ if !args. is_empty ( ) {
1832
1834
all_types. append ( & mut args) ;
1833
1835
} else {
1834
1836
all_types. push ( arg. type_ . clone ( ) ) ;
@@ -1840,10 +1842,8 @@ pub fn get_all_types(
1840
1842
1841
1843
let mut ret_types = match decl. output {
1842
1844
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 {
1845
+ let mut ret = get_real_types ( generics, & return_type, cx) ;
1846
+ if ret. is_empty ( ) {
1847
1847
ret. push ( return_type. clone ( ) ) ;
1848
1848
}
1849
1849
ret
0 commit comments