Skip to content

Commit

Permalink
Merge pull request #235 from dtolnay/patterns
Browse files Browse the repository at this point in the history
Make expansion of nested `_` and `..` patterns edition independent
  • Loading branch information
dtolnay authored Jan 22, 2023
2 parents 125917f + 1c2e90a commit f88c287
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>(T, U);

#[async_trait]
pub trait Trait {
async fn f(arg: Tuple<Droppable, i32>);
}

pub struct UnderscorePattern;

#[async_trait]
impl Trait for UnderscorePattern {
async fn f(Tuple(_, _int): Tuple<Droppable, i32>) {}
}

pub struct DotDotPattern;

#[async_trait]
impl Trait for DotDotPattern {
async fn f(Tuple { 1: _int, .. }: Tuple<Droppable, i32>) {}
}
}

0 comments on commit f88c287

Please sign in to comment.