Skip to content

Commit a7a4796

Browse files
committed
Reduce nesting of items_after_statements workaround
1 parent 6167641 commit a7a4796

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/expand.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,24 +357,25 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
357357
}
358358

359359
let stmts = &block.stmts;
360-
let stmts = if decls.is_empty() {
361-
quote!(#(#stmts)*)
362-
} else {
363-
quote!({ #(#stmts)* })
364-
};
365360
let let_ret = match &mut sig.output {
366361
ReturnType::Default => quote_spanned! {block.brace_token.span=>
367-
let _: () = { #(#decls)* #stmts };
362+
#(#decls)*
363+
let _: () = { #(#stmts)* };
368364
},
369365
ReturnType::Type(_, ret) => {
370366
if contains_associated_type_impl_trait(context, ret) {
371-
quote!(#(#decls)* #stmts)
367+
if decls.is_empty() {
368+
quote!(#(#stmts)*)
369+
} else {
370+
quote!(#(#decls)* { #(#stmts)* })
371+
}
372372
} else {
373373
quote_spanned! {block.brace_token.span=>
374374
if let ::core::option::Option::Some(__ret) = ::core::option::Option::None::<#ret> {
375375
return __ret;
376376
}
377-
let __ret: #ret = { #(#decls)* #stmts };
377+
#(#decls)*
378+
let __ret: #ret = { #(#stmts)* };
378379
#[allow(unreachable_code)]
379380
__ret
380381
}

0 commit comments

Comments
 (0)