From f843fc8a18bd42ba8d1329ed21794fdf618b1718 Mon Sep 17 00:00:00 2001 From: Andy Lok Date: Wed, 19 Jun 2024 23:32:30 +0800 Subject: [PATCH] fix: correctly handle return (#6) --- Cargo.toml | 2 +- src/lib.rs | 8 ++++++-- tests/ui/ok/unreachable.rs | 2 -- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6f365f0..51b26b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "logcall" -version = "0.1.7" +version = "0.1.8" edition = "2021" authors = ["andylokandy "] description = "An attribute macro that logs the function return value." diff --git a/src/lib.rs b/src/lib.rs index 4d5fa66..f4ea04c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -186,7 +186,9 @@ fn gen_block( #[allow(unknown_lints)] #[allow(clippy::useless_format)] let __input_string = format!(#input_format); - let __ret_value = #block; + #[allow(unknown_lints)] + #[allow(clippy::redundant_closure_call)] + let __ret_value = (move || #block)(); #log; __ret_value ); @@ -255,7 +257,9 @@ fn gen_block( #[allow(unknown_lints)] #[allow(clippy::useless_format)] let __input_string = format!(#input_format); - let __ret_value = #block; + #[allow(unknown_lints)] + #[allow(clippy::redundant_closure_call)] + let __ret_value = (move || #block)(); match __ret_value { #ok_arm #err_arm diff --git a/tests/ui/ok/unreachable.rs b/tests/ui/ok/unreachable.rs index 684b548..bb347ff 100644 --- a/tests/ui/ok/unreachable.rs +++ b/tests/ui/ok/unreachable.rs @@ -1,5 +1,3 @@ -#![allow(unreachable_code)] - #[logcall::logcall("info")] async fn f(a: u32) -> u32 { if a == 1 {