@@ -1735,9 +1735,12 @@ fn render_impl(
17351735 . map ( |item| format ! ( "{}.{name}" , item. type_( ) ) ) ;
17361736 write_str (
17371737 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+ ) ,
17391743 ) ;
1740- render_rightside ( w, cx, item, render_mode) ;
17411744 if trait_. is_some ( ) {
17421745 // Anchors are only used on trait impls.
17431746 write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1762,9 +1765,12 @@ fn render_impl(
17621765 let id = cx. derive_id ( & source_id) ;
17631766 write_str (
17641767 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+ ) ,
17661773 ) ;
1767- render_rightside ( w, cx, item, render_mode) ;
17681774 if trait_. is_some ( ) {
17691775 // Anchors are only used on trait impls.
17701776 write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1790,9 +1796,12 @@ fn render_impl(
17901796 let id = cx. derive_id ( & source_id) ;
17911797 write_str (
17921798 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+ ) ,
17941804 ) ;
1795- render_rightside ( w, cx, item, render_mode) ;
17961805 if trait_. is_some ( ) {
17971806 // Anchors are only used on trait impls.
17981807 write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1823,9 +1832,12 @@ fn render_impl(
18231832 let id = cx. derive_id ( & source_id) ;
18241833 write_str (
18251834 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+ ) ,
18271840 ) ;
1828- render_rightside ( w, cx, item, render_mode) ;
18291841 if trait_. is_some ( ) {
18301842 // Anchors are only used on trait impls.
18311843 write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -1851,9 +1863,12 @@ fn render_impl(
18511863 let id = cx. derive_id ( & source_id) ;
18521864 write_str (
18531865 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+ ) ,
18551871 ) ;
1856- render_rightside ( w, cx, item, render_mode) ;
18571872 if trait_. is_some ( ) {
18581873 // Anchors are only used on trait impls.
18591874 write_str ( w, format_args ! ( "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ) ;
@@ -2095,40 +2110,43 @@ fn render_impl(
20952110
20962111// Render the items that appear on the right side of methods, impls, and
20972112// 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 > {
20992118 let tcx = cx. tcx ( ) ;
21002119
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+ ) ;
21092133
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 ( ( ) ) ,
21292148 }
2130- ( None , None ) => { }
2131- }
2149+ } )
21322150}
21332151
21342152pub ( crate ) fn render_impl_summary (
@@ -2150,13 +2168,14 @@ pub(crate) fn render_impl_summary(
21502168 write ! ( f, " data-aliases=\" {}\" " , fmt:: from_fn( |f| aliases. iter( ) . joined( "," , f) ) )
21512169 } ) )
21522170 . maybe_display ( ) ;
2153- write_str ( w, format_args ! ( "<section id=\" {id}\" class=\" impl\" {aliases}>" ) ) ;
2154- render_rightside ( w, cx, & i. impl_item , RenderMode :: Normal ) ;
21552171 write_str (
21562172 w,
21572173 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 )
21602179 ) ,
21612180 ) ;
21622181
0 commit comments