From df8056a458b5119e05fab5a50a9ce5e3edd30024 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 1 Oct 2020 04:51:27 -0700 Subject: [PATCH 1/2] Add regression test for issue 129 --- tests/test.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index 2d8b75b..002fd20 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1025,3 +1025,26 @@ pub mod issue123 { #[async_trait] impl Trait for () {} } + +// https://github.com/dtolnay/async-trait/issues/129 +pub mod issue129 { + #![deny(clippy::pedantic)] + + use async_trait::async_trait; + + #[async_trait] + pub trait TestTrait { + async fn a(_b: u8, c: u8) -> u8 { + c + } + } + + pub struct TestStruct; + + #[async_trait] + impl TestTrait for TestStruct { + async fn a(_b: u8, c: u8) -> u8 { + c + } + } +} From 9a7bb726456892069ed4d90a85b68947bf72cfdb Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 1 Oct 2020 04:52:30 -0700 Subject: [PATCH 2/2] Suppress used_underscore_binding on wrapper function --- src/expand.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/expand.rs b/src/expand.rs index f868c7d..aac8e46 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -72,6 +72,7 @@ pub fn expand(input: &mut Item, is_local: bool) { if let Some(block) = block { has_self |= has_self_in_block(block); transform_block(context, sig, block, has_self, is_local); + method.attrs.push(parse_quote!(#[allow(clippy::used_underscore_binding)])); } let has_default = method.default.is_some(); transform_sig(context, sig, has_self, has_default, is_local); @@ -101,6 +102,7 @@ pub fn expand(input: &mut Item, is_local: bool) { let has_self = has_self_in_sig(sig) || has_self_in_block(block); transform_block(context, sig, block, has_self, is_local); transform_sig(context, sig, has_self, false, is_local); + method.attrs.push(parse_quote!(#[allow(clippy::used_underscore_binding)])); } } }