@@ -264,7 +264,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut String)
264
264
buf,
265
265
format_args ! ( "{}" , item_constant( cx, item, & ci. generics, & ci. type_, & ci. kind) ) ,
266
266
) ,
267
- clean:: ForeignTypeItem => item_foreign_type ( buf, cx, item) ,
267
+ clean:: ForeignTypeItem => write_str ( buf, format_args ! ( "{}" , item_foreign_type ( cx, item) ) ) ,
268
268
clean:: KeywordItem => item_keyword ( buf, cx, item) ,
269
269
clean:: TraitAliasItem ( ref ta) => item_trait_alias ( buf, cx, item, ta) ,
270
270
_ => {
@@ -2122,22 +2122,24 @@ fn item_static<'a, 'tcx>(
2122
2122
} )
2123
2123
}
2124
2124
2125
- fn item_foreign_type ( w : & mut impl fmt:: Write , cx : & Context < ' _ > , it : & clean:: Item ) {
2126
- wrap_item ( w, |buffer| {
2127
- buffer. write_str ( "extern {\n " ) . unwrap ( ) ;
2128
- render_attributes_in_code ( buffer, it, cx) ;
2125
+ fn item_foreign_type < ' a , ' tcx > (
2126
+ cx : & ' a Context < ' tcx > ,
2127
+ it : & ' a clean:: Item ,
2128
+ ) -> impl fmt:: Display + ' a + Captures < ' tcx > {
2129
+ fmt:: from_fn ( |w| {
2130
+ wrap_item ( w, |w| {
2131
+ w. write_str ( "extern {\n " ) ?;
2132
+ render_attributes_in_code ( w, it, cx) ;
2133
+ write ! ( w, " {}type {};\n }}" , visibility_print_with_space( it, cx) , it. name. unwrap( ) , )
2134
+ } ) ?;
2135
+
2129
2136
write ! (
2130
- buffer ,
2131
- " {}type {}; \n } }" ,
2132
- visibility_print_with_space ( it, cx ) ,
2133
- it . name . unwrap ( ) ,
2137
+ w ,
2138
+ "{}{ }" ,
2139
+ document ( cx , it, None , HeadingOffset :: H2 ) ,
2140
+ render_assoc_items ( cx , it , it . item_id . expect_def_id ( ) , AssocItemRender :: All )
2134
2141
)
2135
- . unwrap ( ) ;
2136
- } ) ;
2137
-
2138
- write ! ( w, "{}" , document( cx, it, None , HeadingOffset :: H2 ) ) . unwrap ( ) ;
2139
- write ! ( w, "{}" , render_assoc_items( cx, it, it. item_id. expect_def_id( ) , AssocItemRender :: All ) )
2140
- . unwrap ( ) ;
2142
+ } )
2141
2143
}
2142
2144
2143
2145
fn item_keyword ( w : & mut String , cx : & Context < ' _ > , it : & clean:: Item ) {
0 commit comments