summaryrefslogtreecommitdiffstats
path: root/src/test/ui/transmutability/unions/repr
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
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')
-rw-r--r--src/test/ui/transmutability/unions/repr/should_handle_align.rs47
-rw-r--r--src/test/ui/transmutability/unions/repr/should_handle_packed.rs48
-rw-r--r--src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.rs44
-rw-r--r--src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr49
4 files changed, 0 insertions, 188 deletions
diff --git a/src/test/ui/transmutability/unions/repr/should_handle_align.rs b/src/test/ui/transmutability/unions/repr/should_handle_align.rs
deleted file mode 100644
index 09c13cc4d..000000000
--- a/src/test/ui/transmutability/unions/repr/should_handle_align.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-// check-pass
-//! The presence of an `align(X)` annotation must be accounted for.
-
-#![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_pad_explicitly_aligned_field() {
- #[derive(Clone, Copy)] #[repr(u8)] enum V0u8 { V = 0 }
- #[derive(Clone, Copy)] #[repr(u8)] enum V1u8 { V = 1 }
-
- #[repr(C)]
- pub union Uninit {
- a: (),
- b: V1u8,
- }
-
- #[repr(C, align(2))]
- pub union align_2 {
- a: V0u8,
- }
-
- #[repr(C)] struct ImplicitlyPadded(align_2, V0u8);
- #[repr(C)] struct ExplicitlyPadded(V0u8, Uninit, V0u8);
-
- // An implementation that (incorrectly) does not place a padding byte after
- // `align_2` will, incorrectly, reject the following transmutations.
- assert::is_maybe_transmutable::<ImplicitlyPadded, ExplicitlyPadded>();
- assert::is_maybe_transmutable::<ExplicitlyPadded, ImplicitlyPadded>();
-}
diff --git a/src/test/ui/transmutability/unions/repr/should_handle_packed.rs b/src/test/ui/transmutability/unions/repr/should_handle_packed.rs
deleted file mode 100644
index 24c2abd69..000000000
--- a/src/test/ui/transmutability/unions/repr/should_handle_packed.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-// check-pass
-//! The presence of an `align(X)` annotation must be accounted for.
-
-#![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_pad_explicitly_packed_field() {
- #[derive(Clone, Copy)] #[repr(u8)] enum V0u8 { V = 0 }
- #[derive(Clone, Copy)] #[repr(u8)] enum V1u8 { V = 1 }
- #[derive(Clone, Copy)] #[repr(u8)] enum V2u8 { V = 2 }
- #[derive(Clone, Copy)] #[repr(u32)] enum V3u32 { V = 3 }
-
- #[repr(C)]
- pub union Uninit {
- a: (),
- b: V1u8,
- }
-
- #[repr(C, packed(2))]
- pub union Packed {
- a: [V3u32; 0],
- b: V0u8,
- }
-
- #[repr(C)] struct ImplicitlyPadded(Packed, V2u8);
- #[repr(C)] struct ExplicitlyPadded(V0u8, Uninit, V2u8);
-
- assert::is_maybe_transmutable::<ImplicitlyPadded, ExplicitlyPadded>();
- assert::is_maybe_transmutable::<ExplicitlyPadded, ImplicitlyPadded>();
-}
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>();
-}
diff --git a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr b/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr
deleted file mode 100644
index 523bde85a..000000000
--- a/src/test/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr
+++ /dev/null
@@ -1,49 +0,0 @@
-error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
- --> $DIR/should_require_well_defined_layout.rs:30:48
- |
-LL | assert::is_maybe_transmutable::<repr_rust, ()>();
- | ^^ `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`.
- |
- = help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()`
-note: required by a bound in `is_maybe_transmutable`
- --> $DIR/should_require_well_defined_layout.rs:13:14
- |
-LL | pub fn is_maybe_transmutable<Src, Dst>()
- | --------------------- required by a bound in this
-LL | where
-LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
- | ______________^
-LL | | Assume {
-LL | | alignment: true,
-LL | | lifetimes: true,
-... |
-LL | | }
-LL | | }>
- | |__________^ required by this bound in `is_maybe_transmutable`
-
-error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`.
- --> $DIR/should_require_well_defined_layout.rs:31:43
- |
-LL | assert::is_maybe_transmutable::<u128, repr_rust>();
- | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`.
- |
- = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::repr_rust`
-note: required by a bound in `is_maybe_transmutable`
- --> $DIR/should_require_well_defined_layout.rs:13:14
- |
-LL | pub fn is_maybe_transmutable<Src, Dst>()
- | --------------------- required by a bound in this
-LL | where
-LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
- | ______________^
-LL | | Assume {
-LL | | alignment: true,
-LL | | lifetimes: true,
-... |
-LL | | }
-LL | | }>
- | |__________^ required by this bound in `is_maybe_transmutable`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.