summaryrefslogtreecommitdiffstats
path: root/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs')
-rw-r--r--src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs44
1 files changed, 0 insertions, 44 deletions
diff --git a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs b/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs
deleted file mode 100644
index b1d5f71dc..000000000
--- a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-//! A struct must have a well-defined layout to participate in a transmutation.
-
-#![crate_type = "lib"]
-#![feature(transmutability)]
-#![allow(dead_code, incomplete_features, non_camel_case_types)]
-
-mod assert {
- use std::mem::{Assume, BikeshedIntrinsicFrom};
- pub struct Context;
-
- pub fn is_maybe_transmutable<Src, Dst>()
- where
- Dst: BikeshedIntrinsicFrom<Src, Context, {
- Assume {
- alignment: true,
- lifetimes: true,
- safety: true,
- validity: true,
- }
- }>
- {}
-}
-
-fn should_reject_repr_rust()
-{
- union repr_rust {
- a: u8
- }
-
- assert::is_maybe_transmutable::<repr_rust, ()>(); //~ ERROR cannot be safely transmuted
- assert::is_maybe_transmutable::<u128, repr_rust>(); //~ ERROR cannot be safely transmuted
-}
-
-fn should_accept_repr_C()
-{
- #[repr(C)]
- union repr_c {
- a: u8
- }
-
- struct repr_rust;
- assert::is_maybe_transmutable::<repr_c, ()>();
- assert::is_maybe_transmutable::<u128, repr_c>();
-}