diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b05cd9..ffa4e3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Fixed +- Don't trigger `manual_async_fn` lint when mocking `-> impl Future` methods. ## [0.6.1] - 2024-03-27 ### Fixed diff --git a/tests/it/main.rs b/tests/it/main.rs index 4f3a278..a2c1c12 100644 --- a/tests/it/main.rs +++ b/tests/it/main.rs @@ -2,7 +2,6 @@ #![allow(unused)] #![allow(clippy::disallowed_names)] #![allow(clippy::needless_lifetimes)] -#![allow(clippy::manual_async_fn)] use core::future::Future; diff --git a/unimock_macros/src/unimock/mod.rs b/unimock_macros/src/unimock/mod.rs index 7fed46e..b416f45 100644 --- a/unimock_macros/src/unimock/mod.rs +++ b/unimock_macros/src/unimock/mod.rs @@ -389,6 +389,19 @@ fn def_method_impl( None }; + let allow_lints: proc_macro2::TokenStream = { + let mut lints: Vec = vec![quote! { unused }]; + + if matches!( + method.output_structure.wrapping, + output::OutputWrapping::RpitFuture(_) + ) { + lints.push(quote! { manual_async_fn }); + } + + quote! { #[allow(#(#lints),*)] } + }; + let body = match kind { MethodImplKind::Mock => { let unmock_arm = attr.get_unmock_fn(index).map( @@ -622,7 +635,7 @@ fn def_method_impl( quote_spanned! { span=> #(#mirrored_attrs)* #track_caller - #[allow(unused)] + #allow_lints #method_sig { #body }