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