Skip to content

Commit f88c287

Browse files
authored
Merge pull request #235 from dtolnay/patterns
Make expansion of nested `_` and `..` patterns edition independent
2 parents 125917f + 1c2e90a commit f88c287

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/expand.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
403403
} else {
404404
quote! {
405405
#(#attrs)*
406-
let #pat = #ident;
406+
let #pat = {
407+
let #ident = #ident;
408+
#ident
409+
};
407410
}
408411
}
409412
}

tests/test.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
async_trait_nightly_testing,
33
feature(min_specialization, type_alias_impl_trait)
44
)]
5+
#![deny(rust_2021_compatibility)]
56
#![allow(
67
clippy::let_unit_value,
78
clippy::missing_panics_doc,
@@ -1523,3 +1524,35 @@ pub mod issue232 {
15231524
async fn take_ref(&self, (_a, _b, _c): &(T, T, T)) {}
15241525
}
15251526
}
1527+
1528+
// https://github.com/dtolnay/async-trait/issues/234
1529+
pub mod issue234 {
1530+
use async_trait::async_trait;
1531+
1532+
pub struct Droppable;
1533+
1534+
impl Drop for Droppable {
1535+
fn drop(&mut self) {}
1536+
}
1537+
1538+
pub struct Tuple<T, U>(T, U);
1539+
1540+
#[async_trait]
1541+
pub trait Trait {
1542+
async fn f(arg: Tuple<Droppable, i32>);
1543+
}
1544+
1545+
pub struct UnderscorePattern;
1546+
1547+
#[async_trait]
1548+
impl Trait for UnderscorePattern {
1549+
async fn f(Tuple(_, _int): Tuple<Droppable, i32>) {}
1550+
}
1551+
1552+
pub struct DotDotPattern;
1553+
1554+
#[async_trait]
1555+
impl Trait for DotDotPattern {
1556+
async fn f(Tuple { 1: _int, .. }: Tuple<Droppable, i32>) {}
1557+
}
1558+
}

0 commit comments

Comments
 (0)