Skip to content

Commit

Permalink
fix(macros): items_after_statements Clippy warning, closes #4639
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jul 11, 2022
1 parent 47666c4 commit d3e19e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-command-handler-clippy-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-macros": patch
---

Adjust command imports to fix `items_after_statements` Clippy warning.
8 changes: 2 additions & 6 deletions core/tauri-macros/src/command/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit d3e19e3

Please sign in to comment.