@@ -264,7 +264,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut String)
264264 buf,
265265 format_args ! ( "{}" , item_constant( cx, item, & ci. generics, & ci. type_, & ci. kind) ) ,
266266 ) ,
267- clean:: ForeignTypeItem => item_foreign_type ( buf, cx, item) ,
267+ clean:: ForeignTypeItem => write_str ( buf, format_args ! ( "{}" , item_foreign_type ( cx, item) ) ) ,
268268 clean:: KeywordItem => item_keyword ( buf, cx, item) ,
269269 clean:: TraitAliasItem ( ref ta) => item_trait_alias ( buf, cx, item, ta) ,
270270 _ => {
@@ -2122,22 +2122,24 @@ fn item_static<'a, 'tcx>(
21222122 } )
21232123}
21242124
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+
21292136 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 )
21342141 )
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+ } )
21412143}
21422144
21432145fn item_keyword ( w : & mut String , cx : & Context < ' _ > , it : & clean:: Item ) {
0 commit comments