From cf2dff2b1e3fa55fa5415d524200070d0d7aacfe Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Thu, 5 Jan 2023 09:13:28 +0100 Subject: Move /src/test to /tests --- .../structs/repr/should_handle_align.rs | 43 ---- .../structs/repr/should_handle_packed.rs | 42 ---- .../repr/should_require_well_defined_layout.rs | 83 ------ .../repr/should_require_well_defined_layout.stderr | 279 --------------------- .../structs/should_order_fields_correctly.rs | 36 --- 5 files changed, 483 deletions(-) delete mode 100644 src/test/ui/transmutability/structs/repr/should_handle_align.rs delete mode 100644 src/test/ui/transmutability/structs/repr/should_handle_packed.rs delete mode 100644 src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs delete mode 100644 src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr delete mode 100644 src/test/ui/transmutability/structs/should_order_fields_correctly.rs (limited to 'src/test/ui/transmutability/structs') diff --git a/src/test/ui/transmutability/structs/repr/should_handle_align.rs b/src/test/ui/transmutability/structs/repr/should_handle_align.rs deleted file mode 100644 index ea9bf2a237e..00000000000 --- a/src/test/ui/transmutability/structs/repr/should_handle_align.rs +++ /dev/null @@ -1,43 +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() - where - Dst: BikeshedIntrinsicFrom - {} -} - -fn should_pad_explicitly_aligned_field() { - #[derive(Clone, Copy)] #[repr(u8)] enum V0u8 { V = 0 } - - #[repr(C)] - pub union Uninit { - a: (), - b: V0u8, - } - - #[repr(C, align(2))] struct align_2(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::(); - assert::is_maybe_transmutable::(); -} diff --git a/src/test/ui/transmutability/structs/repr/should_handle_packed.rs b/src/test/ui/transmutability/structs/repr/should_handle_packed.rs deleted file mode 100644 index 17dc995fcd9..00000000000 --- a/src/test/ui/transmutability/structs/repr/should_handle_packed.rs +++ /dev/null @@ -1,42 +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() - where - Dst: BikeshedIntrinsicFrom - {} -} - -fn should_pad_explicitly_packed_field() { - #[derive(Clone, Copy)] #[repr(u8)] enum V0u8 { V = 0 } - #[derive(Clone, Copy)] #[repr(u32)] enum V0u32 { V = 0 } - - #[repr(C)] - pub union Uninit { - a: (), - b: V0u8, - } - - #[repr(C, packed(2))] struct ImplicitlyPadded(V0u8, V0u32); - #[repr(C)] struct ExplicitlyPadded(V0u8, Uninit, V0u8, V0u8, V0u8, V0u8); - - // An implementation that (incorrectly) does not place a padding byte after - // `align_2` will, incorrectly, reject the following transmutations. - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); -} diff --git a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs b/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs deleted file mode 100644 index 9a65b4d702d..00000000000 --- a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.rs +++ /dev/null @@ -1,83 +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() - where - Dst: BikeshedIntrinsicFrom - {} -} - -fn should_reject_repr_rust() -{ - fn unit() { - struct repr_rust; - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn tuple() { - struct repr_rust(); - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn braces() { - struct repr_rust{} - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn aligned() { - #[repr(align(1))] struct repr_rust{} - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn packed() { - #[repr(packed)] struct repr_rust{} - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn nested() { - struct repr_rust; - #[repr(C)] struct repr_c(repr_rust); - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } -} - -fn should_accept_repr_C() -{ - fn unit() { - #[repr(C)] struct repr_c; - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn tuple() { - #[repr(C)] struct repr_c(); - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn braces() { - #[repr(C)] struct repr_c{} - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } -} diff --git a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr b/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr deleted file mode 100644 index 621dbee849f..00000000000 --- a/src/test/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr +++ /dev/null @@ -1,279 +0,0 @@ -error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:28:52 - | -LL | assert::is_maybe_transmutable::(); - | ^^ `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` 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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:29:47 - | -LL | assert::is_maybe_transmutable::(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::unit::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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:34:52 - | -LL | assert::is_maybe_transmutable::(); - | ^^ `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` 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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:35:47 - | -LL | assert::is_maybe_transmutable::(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::tuple::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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:40:52 - | -LL | assert::is_maybe_transmutable::(); - | ^^ `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` 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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:41:47 - | -LL | assert::is_maybe_transmutable::(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `should_reject_repr_rust::braces::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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:46:52 - | -LL | assert::is_maybe_transmutable::(); - | ^^ `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` 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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:47:47 - | -LL | assert::is_maybe_transmutable::(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `aligned::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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:52:52 - | -LL | assert::is_maybe_transmutable::(); - | ^^ `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` 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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:53:47 - | -LL | assert::is_maybe_transmutable::(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `packed::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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:59:49 - | -LL | assert::is_maybe_transmutable::(); - | ^^ `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` 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() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`. - --> $DIR/should_require_well_defined_layout.rs:60:47 - | -LL | assert::is_maybe_transmutable::(); - | ^^^^^^ `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `nested::repr_c` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/should_require_well_defined_layout.rs:13:14 - | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/transmutability/structs/should_order_fields_correctly.rs b/src/test/ui/transmutability/structs/should_order_fields_correctly.rs deleted file mode 100644 index 28724562bad..00000000000 --- a/src/test/ui/transmutability/structs/should_order_fields_correctly.rs +++ /dev/null @@ -1,36 +0,0 @@ -// check-pass -//! The fields of a struct should be laid out in lexical order. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - {} -} - -#[repr(u8)] enum V0 { V = 0 } -#[repr(u8)] enum V1 { V = 1 } -#[repr(u8)] enum V2 { V = 2 } - -#[repr(C)] struct S01(V0, V1); -#[repr(C)] struct S012(V0, V1, V2); - -fn should_order_tag_and_fields_correctly() { - // An implementation that (incorrectly) arranges S01 as [0x01, 0x00] will, - // in principle, reject this transmutation. - assert::is_transmutable::(); - // Again, but with one more field. - assert::is_transmutable::(); -} -- cgit 1.4.1-3-g733a5