Skip to content

Commit

Permalink
fix: Allow manual_async_fn lint when mocking -> impl Future methods
Browse files Browse the repository at this point in the history
  • Loading branch information
audunhalland committed Mar 27, 2024
1 parent bc79d19 commit 6a3396f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(unused)]
#![allow(clippy::disallowed_names)]
#![allow(clippy::needless_lifetimes)]
#![allow(clippy::manual_async_fn)]

use core::future::Future;

Expand Down
15 changes: 14 additions & 1 deletion unimock_macros/src/unimock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,19 @@ fn def_method_impl(
None
};

let allow_lints: proc_macro2::TokenStream = {
let mut lints: Vec<proc_macro2::TokenStream> = 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(
Expand Down Expand Up @@ -622,7 +635,7 @@ fn def_method_impl(
quote_spanned! { span=>
#(#mirrored_attrs)*
#track_caller
#[allow(unused)]
#allow_lints
#method_sig {
#body
}
Expand Down

0 comments on commit 6a3396f

Please sign in to comment.