summaryrefslogtreecommitdiff
path: root/crates/system_action/action_macros/src/lib.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-10-13 14:27:01 +0800
committer魏曹先生 <1992414357@qq.com>2025-10-13 14:27:01 +0800
commit4810f56e6a49b60923eb850d5944457650c81c75 (patch)
treeef02095c73635b5ace574c26dfcb999017e34897 /crates/system_action/action_macros/src/lib.rs
parentacf0804b5f9bdc2796d847919a8ae20103be600a (diff)
Fix Clippy warnings and optimize code
- Fix let_underscore_future warning by properly awaiting async functions - Make accept_import function async to match add_mapping usage - Propagate errors properly with ? operator instead of ignoring them - Replace manual Default implementation with derive attribute - Replace vec! with array literal to avoid useless_vec warning - All tests pass and code is now Clippy clean
Diffstat (limited to 'crates/system_action/action_macros/src/lib.rs')
-rw-r--r--crates/system_action/action_macros/src/lib.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/system_action/action_macros/src/lib.rs b/crates/system_action/action_macros/src/lib.rs
index d1a47ee..ce50073 100644
--- a/crates/system_action/action_macros/src/lib.rs
+++ b/crates/system_action/action_macros/src/lib.rs
@@ -101,7 +101,7 @@ fn generate_action_struct(input_fn: ItemFn, _is_local: bool) -> proc_macro2::Tok
}
fn validate_function_signature(fn_sig: &syn::Signature) {
- if !fn_sig.asyncness.is_some() {
+ if fn_sig.asyncness.is_none() {
panic!("Expected async function for Action, but found synchronous function");
}
@@ -120,13 +120,12 @@ fn validate_function_signature(fn_sig: &syn::Signature) {
};
if let syn::Type::Path(type_path) = return_type.as_ref() {
- if let Some(segment) = type_path.path.segments.last() {
- if segment.ident != "Result" {
+ if let Some(segment) = type_path.path.segments.last()
+ && segment.ident != "Result" {
panic!(
"Expected Action function to return Result<T, TcpTargetError>, but found different return type"
);
}
- }
} else {
panic!(
"Expected Action function to return Result<T, TcpTargetError>, but found no return type"