From 64a54df86faf1f55148433753296dc2bc2a7e31d Mon Sep 17 00:00:00 2001 From: Bryan Garza <1396101+bryangarza@users.noreply.github.com> Date: Wed, 7 Jun 2023 08:17:58 -0700 Subject: [PATCH] Safe Transmute: Disable coinduction support This patch just removes the `#[rustc_coinductive]` annotation from `BikeshedIntrinsicFrom` and flips the related tests to `check-fail`. Once an FCP for setting the annotation on the trait is approved, it could be enabled again. --- library/core/src/mem/transmutability.rs | 1 - .../recursive-wrapper-types-bit-compatible.rs | 5 ++-- ...ursive-wrapper-types-bit-compatible.stderr | 25 +++++++++++++++++++ .../references/recursive-wrapper-types.rs | 5 ++-- .../references/recursive-wrapper-types.stderr | 25 +++++++++++++++++++ 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types.stderr diff --git a/library/core/src/mem/transmutability.rs b/library/core/src/mem/transmutability.rs index d0c30e715d5..87ae30619c6 100644 --- a/library/core/src/mem/transmutability.rs +++ b/library/core/src/mem/transmutability.rs @@ -5,7 +5,6 @@ /// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied. #[unstable(feature = "transmutability", issue = "99571")] #[lang = "transmute_trait"] -#[rustc_coinductive] pub unsafe trait BikeshedIntrinsicFrom where Src: ?Sized, diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs index 709d8cdc762..3ea80173afa 100644 --- a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs @@ -1,4 +1,5 @@ -// check-pass +// check-fail +// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom #![feature(transmutability)] mod assert { @@ -21,5 +22,5 @@ mod assert { fn main() { #[repr(C)] struct A(bool, &'static A); #[repr(C)] struct B(u8, &'static B); - assert::is_maybe_transmutable::<&'static A, &'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 00000000000..fae332e6af9 --- /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.rs b/tests/ui/transmutability/references/recursive-wrapper-types.rs index 090c1fea6db..59d1ad84a5d 100644 --- a/tests/ui/transmutability/references/recursive-wrapper-types.rs +++ b/tests/ui/transmutability/references/recursive-wrapper-types.rs @@ -1,4 +1,5 @@ -// check-pass +// check-fail +// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom #![feature(transmutability)] mod assert { @@ -21,6 +22,6 @@ mod assert { fn main() { #[repr(C)] struct A(&'static B); #[repr(C)] struct B(&'static A); - assert::is_maybe_transmutable::<&'static A, &'static B>(); + 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 00000000000..35a60c22643 --- /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`.