Skip to content

Commit cfa749a

Browse files
committed
Preserve the span on the enclosing braces of a function
Fixes #3
1 parent 3a2f01c commit cfa749a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ pub fn context(args: TokenStream, input: TokenStream) -> TokenStream {
7070
.into()
7171
}
7272
syn::ReturnType::Type(_, return_ty) => {
73-
input.block = syn::parse_quote!({
73+
input.block.stmts = syn::parse_quote!(
7474
let result: #return_ty = async { #body }.await;
7575
result.map_err(|err| err.context(format!(#args)).into())
76-
});
76+
);
7777
}
7878
}
7979
} else {
80-
input.block = syn::parse_quote!({
80+
input.block.stmts = syn::parse_quote!(
8181
(|| #return_ty #body)().map_err(|err| err.context(format!(#args)).into())
82-
});
82+
);
8383
}
8484

8585
quote!(#input).into()

0 commit comments

Comments
 (0)