rust/tests/ui/generator/partial-drop.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
595 B
Rust
Raw Normal View History

2023-06-24 05:02:54 -05:00
// check-pass
#![feature(negative_impls, generators)]
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-14 19:45:00 -06:00
});
assert_send(|| {
2023-06-24 05:02:54 -05:00
let mut guard = Bar { foo: Foo, x: 42 };
2023-05-07 13:38:52 -05:00
drop(guard);
2023-06-24 05:02:54 -05:00
guard = Bar { foo: Foo, x: 23 };
2023-05-07 13:38:52 -05:00
yield;
});
assert_send(|| {
2022-01-14 19:45:00 -06:00
let guard = Bar { foo: Foo, x: 42 };
let Bar { foo, x } = guard;
drop(foo);
yield;
});
}
fn assert_send<T: Send>(_: T) {}