@@ -1735,9 +1735,12 @@ fn render_impl(
1735
1735
. map ( |item| format ! ( "{}.{name}" , item. type_( ) ) ) ;
1736
1736
write_str (
1737
1737
w,
1738
- format_args ! ( "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >" ) ,
1738
+ format_args ! (
1739
+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >\
1740
+ {}",
1741
+ render_rightside( cx, item, render_mode)
1742
+ ) ,
1739
1743
) ;
1740
- render_rightside ( w, cx, item, render_mode) ;
1741
1744
if trait_. is_some ( ) {
1742
1745
// Anchors are only used on trait impls.
1743
1746
write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1762,9 +1765,12 @@ fn render_impl(
1762
1765
let id = cx. derive_id ( & source_id) ;
1763
1766
write_str (
1764
1767
w,
1765
- format_args ! ( "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >" ) ,
1768
+ format_args ! (
1769
+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >\
1770
+ {}",
1771
+ render_rightside( cx, item, render_mode)
1772
+ ) ,
1766
1773
) ;
1767
- render_rightside ( w, cx, item, render_mode) ;
1768
1774
if trait_. is_some ( ) {
1769
1775
// Anchors are only used on trait impls.
1770
1776
write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1790,9 +1796,12 @@ fn render_impl(
1790
1796
let id = cx. derive_id ( & source_id) ;
1791
1797
write_str (
1792
1798
w,
1793
- format_args ! ( "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >" ) ,
1799
+ format_args ! (
1800
+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >\
1801
+ {}",
1802
+ render_rightside( cx, item, render_mode)
1803
+ ) ,
1794
1804
) ;
1795
- render_rightside ( w, cx, item, render_mode) ;
1796
1805
if trait_. is_some ( ) {
1797
1806
// Anchors are only used on trait impls.
1798
1807
write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1823,9 +1832,12 @@ fn render_impl(
1823
1832
let id = cx. derive_id ( & source_id) ;
1824
1833
write_str (
1825
1834
w,
1826
- format_args ! ( "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >" ) ,
1835
+ format_args ! (
1836
+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >\
1837
+ {}",
1838
+ render_rightside( cx, item, render_mode)
1839
+ ) ,
1827
1840
) ;
1828
- render_rightside ( w, cx, item, render_mode) ;
1829
1841
if trait_. is_some ( ) {
1830
1842
// Anchors are only used on trait impls.
1831
1843
write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1851,9 +1863,12 @@ fn render_impl(
1851
1863
let id = cx. derive_id ( & source_id) ;
1852
1864
write_str (
1853
1865
w,
1854
- format_args ! ( "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >" ) ,
1866
+ format_args ! (
1867
+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}\" >\
1868
+ {}",
1869
+ render_rightside( cx, item, render_mode)
1870
+ ) ,
1855
1871
) ;
1856
- render_rightside ( w, cx, item, render_mode) ;
1857
1872
if trait_. is_some ( ) {
1858
1873
// Anchors are only used on trait impls.
1859
1874
write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -2095,40 +2110,43 @@ fn render_impl(
2095
2110
2096
2111
// Render the items that appear on the right side of methods, impls, and
2097
2112
// associated types. For example "1.0.0 (const: 1.39.0) · source".
2098
- fn render_rightside ( w : & mut String , cx : & Context < ' _ > , item : & clean:: Item , render_mode : RenderMode ) {
2113
+ fn render_rightside < ' a , ' tcx > (
2114
+ cx : & ' a Context < ' tcx > ,
2115
+ item : & ' a clean:: Item ,
2116
+ render_mode : RenderMode ,
2117
+ ) -> impl fmt:: Display + ' a + Captures < ' tcx > {
2099
2118
let tcx = cx. tcx ( ) ;
2100
2119
2101
- // FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove
2102
- // this condition.
2103
- let const_stability = match render_mode {
2104
- RenderMode :: Normal => item. const_stability ( tcx) ,
2105
- RenderMode :: ForDeref { .. } => None ,
2106
- } ;
2107
- let src_href = cx. src_href ( item) ;
2108
- let has_src_ref = src_href. is_some ( ) ;
2120
+ fmt:: from_fn ( move |w| {
2121
+ // FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove
2122
+ // this condition.
2123
+ let const_stability = match render_mode {
2124
+ RenderMode :: Normal => item. const_stability ( tcx) ,
2125
+ RenderMode :: ForDeref { .. } => None ,
2126
+ } ;
2127
+ let src_href = cx. src_href ( item) ;
2128
+ let stability = render_stability_since_raw_with_extra (
2129
+ item. stable_since ( tcx) ,
2130
+ const_stability,
2131
+ if src_href. is_some ( ) { "" } else { " rightside" } ,
2132
+ ) ;
2109
2133
2110
- let stability = render_stability_since_raw_with_extra (
2111
- item. stable_since ( tcx) ,
2112
- const_stability,
2113
- if has_src_ref { "" } else { " rightside" } ,
2114
- ) ;
2115
- match ( stability, src_href) {
2116
- ( Some ( stability) , Some ( link) ) => {
2117
- write_str (
2118
- w,
2119
- format_args ! (
2120
- "<span class=\" rightside\" >{stability} · <a class=\" src\" href=\" {link}\" >Source</a></span>"
2121
- ) ,
2122
- ) ;
2123
- }
2124
- ( Some ( stability) , None ) => {
2125
- write_str ( w, format_args ! ( "{stability}" ) ) ;
2126
- }
2127
- ( None , Some ( link) ) => {
2128
- write_str ( w, format_args ! ( "<a class=\" src rightside\" href=\" {link}\" >Source</a>" ) ) ;
2134
+ match ( stability, src_href) {
2135
+ ( Some ( stability) , Some ( link) ) => {
2136
+ write ! (
2137
+ w,
2138
+ "<span class=\" rightside\" >{stability} · <a class=\" src\" href=\" {link}\" >Source</a></span>" ,
2139
+ )
2140
+ }
2141
+ ( Some ( stability) , None ) => {
2142
+ write ! ( w, "{stability}" )
2143
+ }
2144
+ ( None , Some ( link) ) => {
2145
+ write ! ( w, "<a class=\" src rightside\" href=\" {link}\" >Source</a>" )
2146
+ }
2147
+ ( None , None ) => Ok ( ( ) ) ,
2129
2148
}
2130
- ( None , None ) => { }
2131
- }
2149
+ } )
2132
2150
}
2133
2151
2134
2152
pub ( crate ) fn render_impl_summary (
@@ -2150,13 +2168,14 @@ pub(crate) fn render_impl_summary(
2150
2168
write ! ( f, " data-aliases=\" {}\" " , fmt:: from_fn( |f| aliases. iter( ) . joined( "," , f) ) )
2151
2169
} ) )
2152
2170
. maybe_display ( ) ;
2153
- write_str ( w, format_args ! ( "<section id=\" {id}\" class=\" impl\" {aliases}>" ) ) ;
2154
- render_rightside ( w, cx, & i. impl_item , RenderMode :: Normal ) ;
2155
2171
write_str (
2156
2172
w,
2157
2173
format_args ! (
2158
- "<a href=\" #{id}\" class=\" anchor\" >§</a>\
2159
- <h3 class=\" code-header\" >"
2174
+ "<section id=\" {id}\" class=\" impl\" {aliases}>\
2175
+ {}\
2176
+ <a href=\" #{id}\" class=\" anchor\" >§</a>\
2177
+ <h3 class=\" code-header\" >",
2178
+ render_rightside( cx, & i. impl_item, RenderMode :: Normal )
2160
2179
) ,
2161
2180
) ;
2162
2181
0 commit comments