mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-11 07:55:34 +03:00
fix(macros): items_after_statements
Clippy warning, closes #4639
This commit is contained in:
parent
47666c4a0b
commit
d3e19e3420
5
.changes/fix-command-handler-clippy-warn.md
Normal file
5
.changes/fix-command-handler-clippy-warn.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-macros": patch
|
||||
---
|
||||
|
||||
Adjust command imports to fix `items_after_statements` Clippy warning.
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user