From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../primitive_reprs_should_have_correct_length.rs | 156 ------- ...imitive_reprs_should_have_correct_length.stderr | 463 --------------------- .../repr/should_require_well_defined_layout.rs | 124 ------ .../repr/should_require_well_defined_layout.stderr | 141 ------- .../enums/should_order_correctly.rs | 36 -- .../transmutability/enums/should_pad_variants.rs | 45 -- .../enums/should_pad_variants.stderr | 25 -- .../enums/should_respect_endianness.rs | 37 -- .../enums/should_respect_endianness.stderr | 25 -- 9 files changed, 1052 deletions(-) delete mode 100644 src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs delete mode 100644 src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr delete mode 100644 src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs delete mode 100644 src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr delete mode 100644 src/test/ui/transmutability/enums/should_order_correctly.rs delete mode 100644 src/test/ui/transmutability/enums/should_pad_variants.rs delete mode 100644 src/test/ui/transmutability/enums/should_pad_variants.stderr delete mode 100644 src/test/ui/transmutability/enums/should_respect_endianness.rs delete mode 100644 src/test/ui/transmutability/enums/should_respect_endianness.stderr (limited to 'src/test/ui/transmutability/enums') diff --git a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs b/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs deleted file mode 100644 index 940f070e7..000000000 --- a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.rs +++ /dev/null @@ -1,156 +0,0 @@ -//! An enum with a primitive repr should have exactly the size of that primitive. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - {} -} - -#[repr(C)] -struct Zst; - -#[derive(Clone, Copy)] -#[repr(i8)] enum V0i8 { V } -#[repr(u8)] enum V0u8 { V } -#[repr(i16)] enum V0i16 { V } -#[repr(u16)] enum V0u16 { V } -#[repr(i32)] enum V0i32 { V } -#[repr(u32)] enum V0u32 { V } -#[repr(i64)] enum V0i64 { V } -#[repr(u64)] enum V0u64 { V } -#[repr(isize)] enum V0isize { V } -#[repr(usize)] enum V0usize { V } - -fn n8() { - struct Context; - - type Smaller = Zst; - type Analog = u8; - type Larger = u16; - - fn i_should_have_correct_length() { - type Current = V0i8; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn u_should_have_correct_length() { - type Current = V0u8; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } -} - -fn n16() { - struct Context; - - type Smaller = u8; - type Analog = u16; - type Larger = u32; - - fn i_should_have_correct_length() { - type Current = V0i16; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn u_should_have_correct_length() { - type Current = V0u16; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } -} - -fn n32() { - struct Context; - - type Smaller = u16; - type Analog = u32; - type Larger = u64; - - fn i_should_have_correct_length() { - type Current = V0i32; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn u_should_have_correct_length() { - type Current = V0u32; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } -} - -fn n64() { - struct Context; - - type Smaller = u32; - type Analog = u64; - type Larger = u128; - - fn i_should_have_correct_length() { - type Current = V0i64; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn u_should_have_correct_length() { - type Current = V0u64; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } -} - -fn nsize() { - struct Context; - - type Smaller = u8; - type Analog = usize; - type Larger = [usize; 2]; - - fn i_should_have_correct_length() { - type Current = V0isize; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn u_should_have_correct_length() { - type Current = V0usize; - - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted - } -} diff --git a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr b/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr deleted file mode 100644 index 4da5fcea3..000000000 --- a/src/test/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr +++ /dev/null @@ -1,463 +0,0 @@ -error[E0277]: `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:48:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i8` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:50:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:56:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u8` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:58:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u16` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:72:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i16` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:74:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:80:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u16` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:82:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u32` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:96:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i32` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:98:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:104:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u32` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:106:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u64` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:120:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0i64` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:122:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:128:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0u64` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:130:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `u128` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:144:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0isize` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:146:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[usize; 2]` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:152:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `V0usize` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. - --> $DIR/primitive_reprs_should_have_correct_length.rs:154:44 - | -LL | assert::is_transmutable::(); - | ^^^^^^ `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `[usize; 2]` -note: required by a bound in `is_transmutable` - --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error: aborting due to 20 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs b/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs deleted file mode 100644 index 102111ae2..000000000 --- a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.rs +++ /dev/null @@ -1,124 +0,0 @@ -//! An enum must have a well-defined layout to participate in a transmutation. - -#![crate_type = "lib"] -#![feature(repr128)] -#![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 void() { - enum repr_rust {} - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn singleton() { - enum repr_rust { V } - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } - - fn duplex() { - enum repr_rust { A, B } - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - assert::is_maybe_transmutable::(); //~ ERROR cannot be safely transmuted - } -} - -fn should_accept_primitive_reprs() -{ - fn should_accept_repr_i8() { - #[repr(i8)] enum repr_i8 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_u8() { - #[repr(u8)] enum repr_u8 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_i16() { - #[repr(i16)] enum repr_i16 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_u16() { - #[repr(u16)] enum repr_u16 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_i32() { - #[repr(i32)] enum repr_i32 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_u32() { - #[repr(u32)] enum repr_u32 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_i64() { - #[repr(i64)] enum repr_i64 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_u64() { - #[repr(u64)] enum repr_u64 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_i128() { - #[repr(i128)] enum repr_i128 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_u128() { - #[repr(u128)] enum repr_u128 { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_isize() { - #[repr(isize)] enum repr_isize { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } - - fn should_accept_repr_usize() { - #[repr(usize)] enum repr_usize { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); - } -} - -fn should_accept_repr_C() { - #[repr(C)] enum repr_c { V } - assert::is_maybe_transmutable::(); - assert::is_maybe_transmutable::(); -} diff --git a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr b/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr deleted file mode 100644 index 510b8c56e..000000000 --- a/src/test/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr +++ /dev/null @@ -1,141 +0,0 @@ -error[E0277]: `void::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::(); - | ^^ `void::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:14: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 `void::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 `void::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `void::repr_rust` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/should_require_well_defined_layout.rs:14: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]: `singleton::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::(); - | ^^ `singleton::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:14: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 `singleton::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 `singleton::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `singleton::repr_rust` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/should_require_well_defined_layout.rs:14: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]: `duplex::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::(); - | ^^ `duplex::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:14: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 `duplex::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 `duplex::repr_rust` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `duplex::repr_rust` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/should_require_well_defined_layout.rs:14: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 6 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/transmutability/enums/should_order_correctly.rs b/src/test/ui/transmutability/enums/should_order_correctly.rs deleted file mode 100644 index 1335cc9d2..000000000 --- a/src/test/ui/transmutability/enums/should_order_correctly.rs +++ /dev/null @@ -1,36 +0,0 @@ -// check-pass -//! The payloads of an enum variant should be ordered after its tag. - -#![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(u8)] enum E01 { V0(V1) = 0u8 } -#[repr(u8)] enum E012 { V0(V1, V2) = 0u8 } - -fn should_order_tag_and_fields_correctly() { - // An implementation that (incorrectly) arranges E01 as [0x01, 0x00] will, - // in principle, reject this transmutation. - assert::is_transmutable::(); - // Again, but with one more field. - assert::is_transmutable::(); -} diff --git a/src/test/ui/transmutability/enums/should_pad_variants.rs b/src/test/ui/transmutability/enums/should_pad_variants.rs deleted file mode 100644 index c077c52a3..000000000 --- a/src/test/ui/transmutability/enums/should_pad_variants.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! The variants of an enum must be padded with uninit bytes such that they have -//! the same length (in bytes). - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable() - where - Dst: BikeshedIntrinsicFrom - {} -} - -#[derive(Clone, Copy)] -#[repr(C)] struct Zst; - -#[derive(Clone, Copy)] -#[repr(u8)] enum V0 { V = 0 } - -#[derive(Clone, Copy)] -#[repr(u8)] enum V2 { V = 2 } - -#[repr(C, u8)] -enum Lopsided { - Smol(Zst), - Lorg(V0), -} - -#[repr(C)] struct Src(V0, Zst, V2); -#[repr(C)] struct Dst(Lopsided, V2); - -fn should_pad_variants() { - struct Context; - // If the implementation (incorrectly) fails to pad `Lopsided::Smol` with - // an uninitialized byte, this transmutation might be (wrongly) accepted: - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted -} diff --git a/src/test/ui/transmutability/enums/should_pad_variants.stderr b/src/test/ui/transmutability/enums/should_pad_variants.stderr deleted file mode 100644 index a823503d5..000000000 --- a/src/test/ui/transmutability/enums/should_pad_variants.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. - --> $DIR/should_pad_variants.rs:44:36 - | -LL | assert::is_transmutable::(); - | ^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Dst` -note: required by a bound in `is_transmutable` - --> $DIR/should_pad_variants.rs:13:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/transmutability/enums/should_respect_endianness.rs b/src/test/ui/transmutability/enums/should_respect_endianness.rs deleted file mode 100644 index f3567b405..000000000 --- a/src/test/ui/transmutability/enums/should_respect_endianness.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! The target endianness should be a consideration in computing the layout of -//! an enum with a multi-byte tag. - -#![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(u16)] enum Src { V = 0xCAFE } - -#[repr(u8)] enum OxCA { V = 0xCA } -#[repr(u8)] enum OxFE { V = 0xFE } - -#[cfg(target_endian = "big")] #[repr(C)] struct Expected(OxCA, OxFE); -#[cfg(target_endian = "big")] #[repr(C)] struct Unexpected(OxFE, OxCA); - -#[cfg(target_endian = "little")] #[repr(C)] struct Expected(OxFE, OxCA); -#[cfg(target_endian = "little")] #[repr(C)] struct Unexpected(OxCA, OxFE); - -fn should_respect_endianness() { - assert::is_transmutable::(); - assert::is_transmutable::(); //~ ERROR cannot be safely transmuted -} diff --git a/src/test/ui/transmutability/enums/should_respect_endianness.stderr b/src/test/ui/transmutability/enums/should_respect_endianness.stderr deleted file mode 100644 index 0845a5edf..000000000 --- a/src/test/ui/transmutability/enums/should_respect_endianness.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`. - --> $DIR/should_respect_endianness.rs:36:36 - | -LL | assert::is_transmutable::(); - | ^^^^^^^^^^ `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`. - | - = help: the trait `BikeshedIntrinsicFrom` is not implemented for `Unexpected` -note: required by a bound in `is_transmutable` - --> $DIR/should_respect_endianness.rs:14:14 - | -LL | pub fn is_transmutable() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_transmutable` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. -- cgit v1.2.3