diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-16 16:51:43 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-16 16:51:43 +0100 |
commit | 99ad668da45db0d74b74d1e4888f1c286130c6a4 (patch) | |
tree | bf0ebf0d6f05c2bfbcf3e674722e76a42a1c2234 /ffi-macros/src | |
parent | e8d2b7cd2aad554e52e1b0a1fcf7a5647562e327 (diff) |
ffi-macros: Improve translation.
- Use the parenthesis token to preserve location information.
Diffstat (limited to 'ffi-macros/src')
-rw-r--r-- | ffi-macros/src/lib.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ffi-macros/src/lib.rs b/ffi-macros/src/lib.rs index 255c56c8..6a1cfe80 100644 --- a/ffi-macros/src/lib.rs +++ b/ffi-macros/src/lib.rs @@ -54,7 +54,9 @@ pub fn ffi_catch_abort(_attr: TokenStream, item: TokenStream) -> TokenStream { let fn_token = &decl.fn_token; let fn_generics = &decl.generics; let fn_out = &decl.output; - let fn_in = &decl.inputs; + + let mut fn_params = TokenStream2::new(); + decl.paren_token.surround(&mut fn_params, |ts| decl.inputs.to_tokens(ts)); let block = &fun.block; @@ -64,7 +66,7 @@ pub fn ffi_catch_abort(_attr: TokenStream, item: TokenStream) -> TokenStream { // inconsistencies can be observed. let expanded = quote! { #attrs #vis #constness #unsafety #asyncness #abi - #fn_token #ident #fn_generics ( #fn_in ) #fn_out + #fn_token #ident #fn_generics #fn_params #fn_out { match ::std::panic::catch_unwind( ::std::panic::AssertUnwindSafe(|| #fn_out #block)) |