Skip to content

Commit 80a9c2c

Browse files
committed
Add regression test for issue 234
Currently fails to compile: error: changes to closure capture in Rust 2021 will affect drop order --> tests/test.rs:1549:59 | 1549 | async fn f(Tuple(_, _int): Tuple<Droppable, i32>) {} | -------------- ^- | | | | | in Rust 2018, `__arg0` is dropped here, but in Rust 2021, only `__arg0.1` will be dropped here as part of the closure | in Rust 2018, this closure captures all of `__arg0`, but in Rust 2021, it will only capture `__arg0.1` | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> note: the lint level is defined here --> tests/test.rs:5:9 | 5 | #![deny(rust_2021_compatibility)] | ^^^^^^^^^^^^^^^^^^^^^^^ = note: `#[deny(rust_2021_incompatible_closure_captures)]` implied by `#[deny(rust_2021_compatibility)]` help: add a dummy let to cause `__arg0` to be fully captured | 1549 | async fn f(Tuple(_, _int): Tuple<Droppable, i32>) { let _ = &__arg0;} | ++++++++++++++++ error: changes to closure capture in Rust 2021 will affect drop order --> tests/test.rs:1556:66 | 1556 | async fn f(Tuple { 1: _int, .. }: Tuple<Droppable, i32>) {} | --------------------- ^- | | | | | in Rust 2018, `__arg0` is dropped here, but in Rust 2021, only `__arg0.1` will be dropped here as part of the closure | in Rust 2018, this closure captures all of `__arg0`, but in Rust 2021, it will only capture `__arg0.1` | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> help: add a dummy let to cause `__arg0` to be fully captured | 1556 | async fn f(Tuple { 1: _int, .. }: Tuple<Droppable, i32>) { let _ = &__arg0;} | ++++++++++++++++
1 parent 125917f commit 80a9c2c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test.rs

+33
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)