11//@revisions: stack tree
22//@compile-flags: -Zmiri-strict-provenance
33//@[tree]compile-flags: -Zmiri-tree-borrows
4+
5+ // WARNING: If you would ever want to modify this test,
6+ // please consider modifying rustc's async drop test at
7+ // `tests/ui/async-await/async-drop.rs`.
8+
49#![ feature( async_drop, impl_trait_in_assoc_type, noop_waker, async_closure) ]
510#![ allow( incomplete_features, dead_code) ]
611
@@ -11,21 +16,9 @@ use core::mem::{self, ManuallyDrop};
1116use core:: pin:: { pin, Pin } ;
1217use core:: task:: { Context , Poll , Waker } ;
1318
14- async fn test_async_drop < T > ( x : T , _size : usize ) {
19+ async fn test_async_drop < T > ( x : T ) {
1520 let mut x = mem:: MaybeUninit :: new ( x) ;
1621 let dtor = pin ! ( unsafe { async_drop_in_place( x. as_mut_ptr( ) ) } ) ;
17-
18- // FIXME(zetanumbers): This check fully depends on the layout of
19- // the coroutine state, since async destructor combinators are just
20- // async functions.
21- #[ cfg( target_pointer_width = "64" ) ]
22- assert_eq ! (
23- mem:: size_of_val( & * dtor) ,
24- _size,
25- "sizes did not match for async destructor of type {}" ,
26- core:: any:: type_name:: <T >( ) ,
27- ) ;
28-
2922 test_idempotency ( dtor) . await ;
3023}
3124
@@ -46,58 +39,49 @@ fn main() {
4639
4740 let i = 13 ;
4841 let fut = pin ! ( async {
49- test_async_drop( Int ( 0 ) , 0 ) . await ;
50- test_async_drop( AsyncInt ( 0 ) , 104 ) . await ;
51- test_async_drop( [ AsyncInt ( 1 ) , AsyncInt ( 2 ) ] , 152 ) . await ;
52- test_async_drop( ( AsyncInt ( 3 ) , AsyncInt ( 4 ) ) , 488 ) . await ;
53- test_async_drop( 5 , 0 ) . await ;
42+ test_async_drop( Int ( 0 ) ) . await ;
43+ test_async_drop( AsyncInt ( 0 ) ) . await ;
44+ test_async_drop( [ AsyncInt ( 1 ) , AsyncInt ( 2 ) ] ) . await ;
45+ test_async_drop( ( AsyncInt ( 3 ) , AsyncInt ( 4 ) ) ) . await ;
46+ test_async_drop( 5 ) . await ;
5447 let j = 42 ;
55- test_async_drop( & i, 0 ) . await ;
56- test_async_drop( & j, 0 ) . await ;
57- test_async_drop( AsyncStruct { b: AsyncInt ( 8 ) , a: AsyncInt ( 7 ) , i: 6 } , 1688 ) . await ;
58- test_async_drop( ManuallyDrop :: new( AsyncInt ( 9 ) ) , 0 ) . await ;
48+ test_async_drop( & i) . await ;
49+ test_async_drop( & j) . await ;
50+ test_async_drop( AsyncStruct { b: AsyncInt ( 8 ) , a: AsyncInt ( 7 ) , i: 6 } ) . await ;
51+ test_async_drop( ManuallyDrop :: new( AsyncInt ( 9 ) ) ) . await ;
5952
6053 let foo = AsyncInt ( 10 ) ;
61- test_async_drop( AsyncReference { foo: & foo } , 104 ) . await ;
54+ test_async_drop( AsyncReference { foo: & foo } ) . await ;
6255
6356 let foo = AsyncInt ( 11 ) ;
64- test_async_drop(
65- || {
66- black_box( foo) ;
67- let foo = AsyncInt ( 10 ) ;
68- foo
69- } ,
70- 120 ,
71- )
57+ test_async_drop( || {
58+ black_box( foo) ;
59+ let foo = AsyncInt ( 10 ) ;
60+ foo
61+ } )
7262 . await ;
7363
74- test_async_drop( AsyncEnum :: A ( AsyncInt ( 12 ) ) , 680 ) . await ;
75- test_async_drop( AsyncEnum :: B ( SyncInt ( 13 ) ) , 680 ) . await ;
64+ test_async_drop( AsyncEnum :: A ( AsyncInt ( 12 ) ) ) . await ;
65+ test_async_drop( AsyncEnum :: B ( SyncInt ( 13 ) ) ) . await ;
7666
77- test_async_drop( SyncInt ( 14 ) , 16 ) . await ;
78- test_async_drop(
79- SyncThenAsync { i: 15 , a: AsyncInt ( 16 ) , b: SyncInt ( 17 ) , c: AsyncInt ( 18 ) } ,
80- 3064 ,
81- )
82- . await ;
67+ test_async_drop( SyncInt ( 14 ) ) . await ;
68+ test_async_drop( SyncThenAsync { i: 15 , a: AsyncInt ( 16 ) , b: SyncInt ( 17 ) , c: AsyncInt ( 18 ) } )
69+ . await ;
8370
8471 let async_drop_fut = pin!( core:: future:: async_drop( AsyncInt ( 19 ) ) ) ;
8572 test_idempotency( async_drop_fut) . await ;
8673
8774 let foo = AsyncInt ( 20 ) ;
88- test_async_drop(
89- async || {
90- black_box( foo) ;
91- let foo = AsyncInt ( 19 ) ;
92- // Await point there, but this is async closure so it's fine
93- black_box( core:: future:: ready( ( ) ) ) . await ;
94- foo
95- } ,
96- 120 ,
97- )
75+ test_async_drop( async || {
76+ black_box( foo) ;
77+ let foo = AsyncInt ( 19 ) ;
78+ // Await point there, but this is async closure so it's fine
79+ black_box( core:: future:: ready( ( ) ) ) . await ;
80+ foo
81+ } )
9882 . await ;
9983
100- test_async_drop( AsyncUnion { signed: 21 } , 32 ) . await ;
84+ test_async_drop( AsyncUnion { signed: 21 } ) . await ;
10185 } ) ;
10286 let res = fut. poll ( & mut cx) ;
10387 assert_eq ! ( res, Poll :: Ready ( ( ) ) ) ;
0 commit comments