summaryrefslogtreecommitdiffstats
path: root/tests/ui/union/union-unsafe.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/union/union-unsafe.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/ui/union/union-unsafe.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/ui/union/union-unsafe.rs b/tests/ui/union/union-unsafe.rs
index 5e1837a90..d1465486f 100644
--- a/tests/ui/union/union-unsafe.rs
+++ b/tests/ui/union/union-unsafe.rs
@@ -1,30 +1,31 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
-use std::mem::ManuallyDrop;
use std::cell::RefCell;
+use std::mem::ManuallyDrop;
union U1 {
- a: u8
+ a: u8,
}
union U2 {
- a: ManuallyDrop<String>
+ a: ManuallyDrop<String>,
}
union U3<T> {
- a: ManuallyDrop<T>
+ a: ManuallyDrop<T>,
}
union U4<T: Copy> {
- a: T
+ a: T,
}
union URef {
p: &'static mut i32,
}
-union URefCell { // field that does not drop but is not `Copy`, either
+union URefCell {
+ // field that does not drop but is not `Copy`, either
a: (ManuallyDrop<RefCell<i32>>, i32),
}
@@ -62,6 +63,7 @@ fn main() {
let U1 { a } = u1; //~ ERROR access to union field is unsafe
if let U1 { a: 12 } = u1 {} //~ ERROR access to union field is unsafe
+ if let Some(U1 { a: 13 }) = Some(u1) {} //~ ERROR access to union field is unsafe
// let U1 { .. } = u1; // OK
let mut u2 = U2 { a: ManuallyDrop::new(String::from("old")) }; // OK