rust/tests/ui/nll/issue-55651.rs

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

29 lines
501 B
Rust
Raw Normal View History

// check-pass
2022-06-30 02:33:18 +00:00
use std::mem::ManuallyDrop;
struct A;
struct B;
union U {
2022-06-30 02:33:18 +00:00
a: ManuallyDrop<A>,
b: ManuallyDrop<B>,
}
fn main() {
unsafe {
{
2022-06-30 02:33:18 +00:00
let mut u = U { a: ManuallyDrop::new(A) };
let a = u.a;
2022-06-30 02:33:18 +00:00
u.a = ManuallyDrop::new(A);
let a = u.a; // OK
}
{
2022-06-30 02:33:18 +00:00
let mut u = U { a: ManuallyDrop::new(A) };
let a = u.a;
2022-06-30 02:33:18 +00:00
u.b = ManuallyDrop::new(B);
let a = u.a; // OK
}
}
}