@@ -1755,55 +1755,59 @@ fn get_real_types(
17551755 generics : & Generics ,
17561756 arg : & Type ,
17571757 cx : & DocContext < ' _ , ' _ , ' _ > ,
1758- ) -> Option < Vec < Type > > {
1758+ ) -> Vec < Type > {
1759+ let arg_s = arg. to_string ( ) ;
17591760 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+ }
17791783 }
17801784 }
17811785 }
1786+ _ => { }
17821787 }
1783- _ => { }
17841788 }
17851789 }
1786- } else {
1787- let arg_s = arg. to_string ( ) ;
17881790 if let Some ( bound) = generics. params . iter ( ) . find ( |g| {
17891791 g. is_type ( ) && g. name == arg_s
17901792 } ) {
17911793 for bound in bound. get_bounds ( ) . unwrap_or_else ( || & [ ] ) {
17921794 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 ( ) {
17941797 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 ( ) ) ;
17991800 }
18001801 }
18011802 }
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 ( ) {
18041807 for gen in gens. iter ( ) {
18051808 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 ( ) {
18071811 res. append ( & mut adds) ;
18081812 }
18091813 } else {
@@ -1812,10 +1816,7 @@ fn get_real_types(
18121816 }
18131817 }
18141818 }
1815- if res. is_empty ( ) && !arg. is_full_generic ( ) {
1816- res. push ( arg. clone ( ) ) ;
1817- }
1818- Some ( res)
1819+ res
18191820}
18201821
18211822pub fn get_all_types (
@@ -1828,7 +1829,8 @@ pub fn get_all_types(
18281829 if arg. type_ . is_self_type ( ) {
18291830 continue ;
18301831 }
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 ( ) {
18321834 all_types. append ( & mut args) ;
18331835 } else {
18341836 all_types. push ( arg. type_ . clone ( ) ) ;
@@ -1840,10 +1842,8 @@ pub fn get_all_types(
18401842
18411843 let mut ret_types = match decl. output {
18421844 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 ( ) {
18471847 ret. push ( return_type. clone ( ) ) ;
18481848 }
18491849 ret
0 commit comments