From dc0db358abe19481e475e10c32149b53370f1a1c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:31 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- .../recursive-wrapper-types-bit-compatible-mut.rs | 25 ++++++++++++++++++++ ...cursive-wrapper-types-bit-compatible-mut.stderr | 25 ++++++++++++++++++++ .../recursive-wrapper-types-bit-compatible.rs | 26 +++++++++++++++++++++ .../recursive-wrapper-types-bit-compatible.stderr | 25 ++++++++++++++++++++ .../recursive-wrapper-types-bit-incompatible.rs | 25 ++++++++++++++++++++ ...recursive-wrapper-types-bit-incompatible.stderr | 25 ++++++++++++++++++++ .../references/recursive-wrapper-types.rs | 27 ++++++++++++++++++++++ .../references/recursive-wrapper-types.stderr | 25 ++++++++++++++++++++ tests/ui/transmutability/references/u8-to-unit.rs | 24 +++++++++++++++++++ .../transmutability/references/unit-to-itself.rs | 24 +++++++++++++++++++ tests/ui/transmutability/references/unit-to-u8.rs | 24 +++++++++++++++++++ .../transmutability/references/unit-to-u8.stderr | 25 ++++++++++++++++++++ 12 files changed, 300 insertions(+) create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types.stderr create mode 100644 tests/ui/transmutability/references/u8-to-unit.rs create mode 100644 tests/ui/transmutability/references/unit-to-itself.rs create mode 100644 tests/ui/transmutability/references/unit-to-u8.rs create mode 100644 tests/ui/transmutability/references/unit-to-u8.stderr (limited to 'tests/ui/transmutability/references') diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs new file mode 100644 index 000000000..a6e2889d3 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs @@ -0,0 +1,25 @@ +// check-fail +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(bool, &'static A); + #[repr(C)] struct B(u8, &'static B); + assert::is_maybe_transmutable::<&'static A, &'static mut B>(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr new file mode 100644 index 000000000..4b4d6ad02 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr @@ -0,0 +1,25 @@ +error[E0277]: `&A` cannot be safely transmuted into `&mut B` in the defining scope of `assert::Context` + --> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:24:49 + | +LL | assert::is_maybe_transmutable::<&'static A, &'static mut B>(); + | ^^^^^^^^^^^^^^ `&A` is a shared reference, but `&mut B` is a unique reference + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:10:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs new file mode 100644 index 000000000..3ea80173a --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs @@ -0,0 +1,26 @@ +// check-fail +// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(bool, &'static A); + #[repr(C)] struct B(u8, &'static B); + assert::is_maybe_transmutable::<&'static A, &'static B>(); //~ ERROR overflow evaluating the requirement +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr new file mode 100644 index 000000000..fae332e6a --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr @@ -0,0 +1,25 @@ +error[E0275]: overflow evaluating the requirement `B: BikeshedIntrinsicFrom` + --> $DIR/recursive-wrapper-types-bit-compatible.rs:25:5 + | +LL | assert::is_maybe_transmutable::<&'static A, &'static B>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types-bit-compatible.rs:11:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs new file mode 100644 index 000000000..e8582d2fd --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs @@ -0,0 +1,25 @@ +// check-fail +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(bool, &'static A); + #[repr(C)] struct B(u8, &'static B); + assert::is_maybe_transmutable::<&'static B, &'static A>(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr new file mode 100644 index 000000000..ecfe48659 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr @@ -0,0 +1,25 @@ +error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context` + --> $DIR/recursive-wrapper-types-bit-incompatible.rs:24:49 + | +LL | assert::is_maybe_transmutable::<&'static B, &'static A>(); + | ^^^^^^^^^^ At least one value of `B` isn't a bit-valid value of `A` + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types-bit-incompatible.rs:10:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types.rs b/tests/ui/transmutability/references/recursive-wrapper-types.rs new file mode 100644 index 000000000..59d1ad84a --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types.rs @@ -0,0 +1,27 @@ +// check-fail +// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(&'static B); + #[repr(C)] struct B(&'static A); + assert::is_maybe_transmutable::<&'static A, &'static B>(); //~ overflow evaluating the requirement + assert::is_maybe_transmutable::<&'static B, &'static A>(); +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types.stderr b/tests/ui/transmutability/references/recursive-wrapper-types.stderr new file mode 100644 index 000000000..35a60c226 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types.stderr @@ -0,0 +1,25 @@ +error[E0275]: overflow evaluating the requirement `A: BikeshedIntrinsicFrom` + --> $DIR/recursive-wrapper-types.rs:25:5 + | +LL | assert::is_maybe_transmutable::<&'static A, &'static B>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types.rs:11:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/transmutability/references/u8-to-unit.rs b/tests/ui/transmutability/references/u8-to-unit.rs new file mode 100644 index 000000000..8b37492bd --- /dev/null +++ b/tests/ui/transmutability/references/u8-to-unit.rs @@ -0,0 +1,24 @@ +// check-pass +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct Unit; + assert::is_maybe_transmutable::<&'static u8, &'static Unit>(); +} diff --git a/tests/ui/transmutability/references/unit-to-itself.rs b/tests/ui/transmutability/references/unit-to-itself.rs new file mode 100644 index 000000000..04a7e16d7 --- /dev/null +++ b/tests/ui/transmutability/references/unit-to-itself.rs @@ -0,0 +1,24 @@ +// check-pass +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct Unit; + assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); +} diff --git a/tests/ui/transmutability/references/unit-to-u8.rs b/tests/ui/transmutability/references/unit-to-u8.rs new file mode 100644 index 000000000..eff516e9a --- /dev/null +++ b/tests/ui/transmutability/references/unit-to-u8.rs @@ -0,0 +1,24 @@ +// check-fail +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct Unit; + assert::is_maybe_transmutable::<&'static Unit, &'static u8>(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/references/unit-to-u8.stderr b/tests/ui/transmutability/references/unit-to-u8.stderr new file mode 100644 index 000000000..f2b72357f --- /dev/null +++ b/tests/ui/transmutability/references/unit-to-u8.stderr @@ -0,0 +1,25 @@ +error[E0277]: `Unit` cannot be safely transmuted into `u8` in the defining scope of `assert::Context` + --> $DIR/unit-to-u8.rs:23:52 + | +LL | assert::is_maybe_transmutable::<&'static Unit, &'static u8>(); + | ^^^^^^^^^^^ The size of `Unit` is smaller than the size of `u8` + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/unit-to-u8.rs:10:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. -- cgit v1.2.3