@@ -1784,13 +1784,64 @@ fn render_impl(
1784
1784
let mut default_impl_items = Buffer :: empty_from ( w) ;
1785
1785
let impl_ = i. inner_impl ( ) ;
1786
1786
1787
+ // Impl items are grouped by kinds:
1788
+ //
1789
+ // 1. Types
1790
+ // 2. Constants
1791
+ // 3. Functions
1792
+ //
1793
+ // This order is because you can have associated types in associated constants, and both in
1794
+ // associcated functions. So with this order, when reading from top to bottom, you should always
1795
+ // see all items definitions before they're actually used.
1796
+ let mut assoc_consts = Vec :: new ( ) ;
1797
+ let mut methods = Vec :: new ( ) ;
1798
+
1787
1799
if !impl_. is_negative_trait_impl ( ) {
1788
1800
for trait_item in & impl_. items {
1801
+ match * trait_item. kind {
1802
+ clean:: MethodItem ( ..) | clean:: TyMethodItem ( _) => methods. push ( trait_item) ,
1803
+ clean:: TyAssocConstItem ( ..) | clean:: AssocConstItem ( _) => {
1804
+ assoc_consts. push ( trait_item)
1805
+ }
1806
+ clean:: TyAssocTypeItem ( ..) | clean:: AssocTypeItem ( ..) => {
1807
+ // We render it directly since they're supposed to come first.
1808
+ doc_impl_item (
1809
+ & mut default_impl_items,
1810
+ & mut impl_items,
1811
+ cx,
1812
+ trait_item,
1813
+ if trait_. is_some ( ) { & i. impl_item } else { parent } ,
1814
+ link,
1815
+ render_mode,
1816
+ false ,
1817
+ trait_,
1818
+ rendering_params,
1819
+ ) ;
1820
+ }
1821
+ _ => { }
1822
+ }
1823
+ }
1824
+
1825
+ for assoc_const in assoc_consts {
1789
1826
doc_impl_item (
1790
1827
& mut default_impl_items,
1791
1828
& mut impl_items,
1792
1829
cx,
1793
- trait_item,
1830
+ assoc_const,
1831
+ if trait_. is_some ( ) { & i. impl_item } else { parent } ,
1832
+ link,
1833
+ render_mode,
1834
+ false ,
1835
+ trait_,
1836
+ rendering_params,
1837
+ ) ;
1838
+ }
1839
+ for method in methods {
1840
+ doc_impl_item (
1841
+ & mut default_impl_items,
1842
+ & mut impl_items,
1843
+ cx,
1844
+ method,
1794
1845
if trait_. is_some ( ) { & i. impl_item } else { parent } ,
1795
1846
link,
1796
1847
render_mode,
0 commit comments