@@ -1755,35 +1755,24 @@ pub fn get_real_types(
1755
1755
generics : & Generics ,
1756
1756
arg : & Type ,
1757
1757
cx : & DocContext < ' _ , ' _ , ' _ > ,
1758
- debug : bool ,
1759
1758
) -> Option < Vec < Type > > {
1760
1759
let mut res = Vec :: new ( ) ;
1761
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1762
- println ! ( "0. {:?}" , arg) ;
1763
- }
1764
1760
if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| {
1765
1761
match g {
1766
1762
& WherePredicate :: BoundPredicate { ref ty, .. } => ty. def_id ( ) == arg. def_id ( ) ,
1767
1763
_ => false ,
1768
1764
}
1769
1765
} ) {
1770
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1771
- println ! ( "1. {:?} => {:?}" , arg, where_pred) ;
1772
- }
1773
1766
let bounds = where_pred. get_bounds ( ) . unwrap_or_else ( || & [ ] ) ;
1774
1767
for bound in bounds. iter ( ) {
1775
1768
match * bound {
1776
1769
GenericBound :: TraitBound ( ref poly_trait, _) => {
1777
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1778
- println ! ( " {:?}" , poly_trait. trait_) ;
1779
- }
1780
1770
for x in poly_trait. generic_params . iter ( ) {
1781
1771
if !x. is_type ( ) {
1782
1772
continue
1783
1773
}
1784
1774
if let Some ( ty) = x. get_type ( cx) {
1785
- if let Some ( mut adds) = get_real_types ( generics, & ty, cx,
1786
- arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug) {
1775
+ if let Some ( mut adds) = get_real_types ( generics, & ty, cx) {
1787
1776
res. append ( & mut adds) ;
1788
1777
} else if !ty. is_full_generic ( ) {
1789
1778
res. push ( ty) ;
@@ -1799,51 +1788,25 @@ pub fn get_real_types(
1799
1788
if let Some ( bound) = generics. params . iter ( ) . find ( |g| {
1800
1789
g. is_type ( ) && g. name == arg_s
1801
1790
} ) {
1802
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1803
- println ! ( "2. {:?} => {:?}" , arg, bound) ;
1804
- }
1805
1791
for bound in bound. get_bounds ( ) . unwrap_or_else ( || & [ ] ) {
1806
1792
if let Some ( ty) = bound. get_trait_type ( ) {
1807
- if let Some ( mut adds) = get_real_types ( generics, & ty, cx,
1808
- arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug) {
1809
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1810
- println ! ( "3. {:?}" , adds) ;
1811
- }
1793
+ if let Some ( mut adds) = get_real_types ( generics, & ty, cx) {
1812
1794
res. append ( & mut adds) ;
1813
1795
} else {
1814
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1815
- println ! ( "4. {:?}" , ty) ;
1816
- }
1817
1796
if !ty. is_full_generic ( ) {
1818
1797
res. push ( ty. clone ( ) ) ;
1819
1798
}
1820
1799
}
1821
1800
}
1822
1801
}
1823
- /*if let Some(ty) = bound.get_type(cx) {
1824
- if let Some(mut adds) = get_real_types(generics, &ty, cx, level + 1) {
1825
- res.append(&mut adds);
1826
- } else {
1827
- res.push(ty);
1828
- }
1829
- } else {
1830
- res.push(arg.clone());
1831
- }*/
1832
1802
} else if let Some ( gens) = arg. generics ( ) {
1833
1803
res. push ( arg. clone ( ) ) ;
1834
1804
for gen in gens. iter ( ) {
1835
1805
if gen. is_full_generic ( ) {
1836
- if let Some ( mut adds) = get_real_types ( generics, gen, cx,
1837
- arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug) {
1838
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1839
- println ! ( "5. {:?}" , adds) ;
1840
- }
1806
+ if let Some ( mut adds) = get_real_types ( generics, gen, cx) {
1841
1807
res. append ( & mut adds) ;
1842
1808
}
1843
1809
} else {
1844
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1845
- println ! ( "6. {:?}" , gen ) ;
1846
- }
1847
1810
res. push ( gen. clone ( ) ) ;
1848
1811
}
1849
1812
}
@@ -1852,9 +1815,6 @@ pub fn get_real_types(
1852
1815
if res. is_empty ( ) && !arg. is_full_generic ( ) {
1853
1816
res. push ( arg. clone ( ) ) ;
1854
1817
}
1855
- if arg. to_string ( ) == "W" || arg. to_string ( ) == "Z" || debug {
1856
- println ! ( "7. /!\\ {:?}" , res) ;
1857
- }
1858
1818
Some ( res)
1859
1819
}
1860
1820
@@ -1868,17 +1828,15 @@ pub fn get_all_types(
1868
1828
if arg. type_ . is_self_type ( ) {
1869
1829
continue ;
1870
1830
}
1871
- if let Some ( mut args) = get_real_types ( generics, & arg. type_ , cx, false ) {
1831
+ if let Some ( mut args) = get_real_types ( generics, & arg. type_ , cx) {
1872
1832
all_types. append ( & mut args) ;
1873
1833
} else {
1874
1834
all_types. push ( arg. type_ . clone ( ) ) ;
1875
1835
}
1876
1836
}
1877
- all_types. sort_unstable_by ( |a, b| a. to_string ( ) . partial_cmp ( & b. to_string ( ) ) . expect ( "a" ) ) ;
1837
+ // FIXME: use a HashSet instead?
1838
+ all_types. sort_unstable_by ( |a, b| a. to_string ( ) . partial_cmp ( & b. to_string ( ) ) . unwrap ( ) ) ;
1878
1839
all_types. dedup ( ) ;
1879
- if decl. inputs . values . iter ( ) . any ( |s| s. type_ . to_string ( ) == "W" || s. type_ . to_string ( ) == "Z" ) {
1880
- println ! ( "||||> {:?}" , all_types) ;
1881
- }
1882
1840
all_types
1883
1841
}
1884
1842
0 commit comments