diff --git a/src/expand.rs b/src/expand.rs index 7747e68..c2cfacb 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -403,7 +403,10 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { } else { quote! { #(#attrs)* - let #pat = #ident; + let #pat = { + let #ident = #ident; + #ident + }; } } } diff --git a/tests/test.rs b/tests/test.rs index 211387a..2d7dc65 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2,6 +2,7 @@ async_trait_nightly_testing, feature(min_specialization, type_alias_impl_trait) )] +#![deny(rust_2021_compatibility)] #![allow( clippy::let_unit_value, clippy::missing_panics_doc, @@ -1523,3 +1524,35 @@ pub mod issue232 { async fn take_ref(&self, (_a, _b, _c): &(T, T, T)) {} } } + +// https://github.com/dtolnay/async-trait/issues/234 +pub mod issue234 { + use async_trait::async_trait; + + pub struct Droppable; + + impl Drop for Droppable { + fn drop(&mut self) {} + } + + pub struct Tuple(T, U); + + #[async_trait] + pub trait Trait { + async fn f(arg: Tuple); + } + + pub struct UnderscorePattern; + + #[async_trait] + impl Trait for UnderscorePattern { + async fn f(Tuple(_, _int): Tuple) {} + } + + pub struct DotDotPattern; + + #[async_trait] + impl Trait for DotDotPattern { + async fn f(Tuple { 1: _int, .. }: Tuple) {} + } +}