浏览代码

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

Lucas Nogueira 3 年之前
父节点
当前提交
d3e19e3420
共有 2 个文件被更改,包括 7 次插入6 次删除
  1. 5 0
      .changes/fix-command-handler-clippy-warn.md
  2. 2 6
      core/tauri-macros/src/command/wrapper.rs

+ 5 - 0
.changes/fix-command-handler-clippy-warn.md

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

+ 2 - 6
core/tauri-macros/src/command/wrapper.rs

@@ -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);