mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
aef0f4024a
And suggest adding the `#[coroutine]` to the closure
44 lines
782 B
Rust
44 lines
782 B
Rust
//@ check-pass
|
|
#![feature(negative_impls, coroutines, stmt_expr_attributes)]
|
|
|
|
struct Foo;
|
|
impl !Send for Foo {}
|
|
|
|
struct Bar {
|
|
foo: Foo,
|
|
x: i32,
|
|
}
|
|
|
|
fn main() {
|
|
assert_send(
|
|
#[coroutine]
|
|
|| {
|
|
let guard = Bar { foo: Foo, x: 42 };
|
|
drop(guard.foo);
|
|
yield;
|
|
},
|
|
);
|
|
|
|
assert_send(
|
|
#[coroutine]
|
|
|| {
|
|
let mut guard = Bar { foo: Foo, x: 42 };
|
|
drop(guard);
|
|
guard = Bar { foo: Foo, x: 23 };
|
|
yield;
|
|
},
|
|
);
|
|
|
|
assert_send(
|
|
#[coroutine]
|
|
|| {
|
|
let guard = Bar { foo: Foo, x: 42 };
|
|
let Bar { foo, x } = guard;
|
|
drop(foo);
|
|
yield;
|
|
},
|
|
);
|
|
}
|
|
|
|
fn assert_send<T: Send>(_: T) {}
|