fix(macros): items_after_statements Clippy warning, closes #4639

This commit is contained in:
Lucas Nogueira 2022-07-11 16:11:01 -03:00
parent 47666c4a0b
commit d3e19e3420
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1
2 changed files with 7 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-macros": patch
---
Adjust command imports to fix `items_after_statements` Clippy warning.

View File

@ -82,6 +82,8 @@ pub fn wrapper(attributes: TokenStream, item: TokenStream) -> TokenStream {
macro_rules! #wrapper {
// double braces because the item is expected to be a block expression
($path:path, $invoke:ident) => {{
#[allow(unused_imports)]
use ::tauri::command::private::*;
// prevent warnings when the body is a `compile_error!` or if the command has no arguments
#[allow(unused_variables)]
let ::tauri::Invoke { message: #message, resolver: #resolver } = $invoke;
@ -106,9 +108,6 @@ fn body_async(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2> {
let Invoke { message, resolver } = invoke;
parse_args(function, message).map(|args| {
quote! {
#[allow(unused_imports)]
use ::tauri::command::private::*;
#resolver.respond_async_serialized(async move {
let result = $path(#(#args?),*);
let kind = (&result).async_kind();
@ -134,9 +133,6 @@ fn body_blocking(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2
});
Ok(quote! {
#[allow(unused_imports)]
use ::tauri::command::private::*;
let result = $path(#(match #args #match_body),*);
let kind = (&result).blocking_kind();
kind.block(result, #resolver);