@@ -3218,7 +3218,7 @@ pub(crate) mod printing {
3218
3218
Expr :: Call ( e) => print_expr_call ( e, tokens, fixup) ,
3219
3219
Expr :: Cast ( e) => print_expr_cast ( e, tokens, fixup) ,
3220
3220
#[ cfg( feature = "full" ) ]
3221
- Expr :: Closure ( e) => e . to_tokens ( tokens) ,
3221
+ Expr :: Closure ( e) => print_expr_closure ( e , tokens, fixup ) ,
3222
3222
#[ cfg( feature = "full" ) ]
3223
3223
Expr :: Const ( e) => e. to_tokens ( tokens) ,
3224
3224
#[ cfg( feature = "full" ) ]
@@ -3485,25 +3485,30 @@ pub(crate) mod printing {
3485
3485
#[ cfg_attr( docsrs, doc( cfg( feature = "printing" ) ) ) ]
3486
3486
impl ToTokens for ExprClosure {
3487
3487
fn to_tokens ( & self , tokens : & mut TokenStream ) {
3488
- outer_attrs_to_tokens ( & self . attrs , tokens) ;
3489
- self . lifetimes . to_tokens ( tokens) ;
3490
- self . constness . to_tokens ( tokens) ;
3491
- self . movability . to_tokens ( tokens) ;
3492
- self . asyncness . to_tokens ( tokens) ;
3493
- self . capture . to_tokens ( tokens) ;
3494
- self . or1_token . to_tokens ( tokens) ;
3495
- self . inputs . to_tokens ( tokens) ;
3496
- self . or2_token . to_tokens ( tokens) ;
3497
- self . output . to_tokens ( tokens) ;
3498
- if matches ! ( self . output, ReturnType :: Default )
3499
- || matches ! ( & * self . body, Expr :: Block ( body) if body. attrs. is_empty( ) && body. label. is_none( ) )
3500
- {
3501
- self . body . to_tokens ( tokens) ;
3502
- } else {
3503
- token:: Brace :: default ( ) . surround ( tokens, |tokens| {
3504
- print_expr ( & self . body , tokens, FixupContext :: new_stmt ( ) ) ;
3505
- } ) ;
3506
- }
3488
+ print_expr_closure ( self , tokens, FixupContext :: NONE ) ;
3489
+ }
3490
+ }
3491
+
3492
+ #[ cfg( feature = "full" ) ]
3493
+ fn print_expr_closure ( e : & ExprClosure , tokens : & mut TokenStream , fixup : FixupContext ) {
3494
+ outer_attrs_to_tokens ( & e. attrs , tokens) ;
3495
+ e. lifetimes . to_tokens ( tokens) ;
3496
+ e. constness . to_tokens ( tokens) ;
3497
+ e. movability . to_tokens ( tokens) ;
3498
+ e. asyncness . to_tokens ( tokens) ;
3499
+ e. capture . to_tokens ( tokens) ;
3500
+ e. or1_token . to_tokens ( tokens) ;
3501
+ e. inputs . to_tokens ( tokens) ;
3502
+ e. or2_token . to_tokens ( tokens) ;
3503
+ e. output . to_tokens ( tokens) ;
3504
+ if matches ! ( e. output, ReturnType :: Default )
3505
+ || matches ! ( & * e. body, Expr :: Block ( body) if body. attrs. is_empty( ) && body. label. is_none( ) )
3506
+ {
3507
+ print_expr ( & e. body , tokens, fixup. rightmost_subexpression ( ) ) ;
3508
+ } else {
3509
+ token:: Brace :: default ( ) . surround ( tokens, |tokens| {
3510
+ print_expr ( & e. body , tokens, FixupContext :: new_stmt ( ) ) ;
3511
+ } ) ;
3507
3512
}
3508
3513
}
3509
3514
0 commit comments