2023-06-24 05:02:54 -05:00
|
|
|
//@ check-pass
|
2024-04-11 08:15:34 -05:00
|
|
|
#![feature(negative_impls, coroutines, stmt_expr_attributes)]
|
2021-12-13 12:47:28 -06:00
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
impl !Send for Foo {}
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
foo: Foo,
|
|
|
|
x: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2024-04-11 08:15:34 -05:00
|
|
|
assert_send(
|
|
|
|
#[coroutine]
|
|
|
|
|| {
|
|
|
|
let guard = Bar { foo: Foo, x: 42 };
|
|
|
|
drop(guard.foo);
|
|
|
|
yield;
|
|
|
|
},
|
|
|
|
);
|
2022-01-14 19:45:00 -06:00
|
|
|
|
2024-04-11 08:15:34 -05:00
|
|
|
assert_send(
|
|
|
|
#[coroutine]
|
|
|
|
|| {
|
|
|
|
let mut guard = Bar { foo: Foo, x: 42 };
|
|
|
|
drop(guard);
|
|
|
|
guard = Bar { foo: Foo, x: 23 };
|
|
|
|
yield;
|
|
|
|
},
|
|
|
|
);
|
2023-05-07 13:38:52 -05:00
|
|
|
|
2024-04-11 08:15:34 -05:00
|
|
|
assert_send(
|
|
|
|
#[coroutine]
|
|
|
|
|| {
|
|
|
|
let guard = Bar { foo: Foo, x: 42 };
|
|
|
|
let Bar { foo, x } = guard;
|
|
|
|
drop(foo);
|
|
|
|
yield;
|
|
|
|
},
|
|
|
|
);
|
2021-12-13 12:47:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn assert_send<T: Send>(_: T) {}
|