Skip to content

Commit 64a54df

Browse files
committed
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.
1 parent d2164d5 commit 64a54df

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

library/core/src/mem/transmutability.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied.
66
#[unstable(feature = "transmutability", issue = "99571")]
77
#[lang = "transmute_trait"]
8-
#[rustc_coinductive]
98
pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }>
109
where
1110
Src: ?Sized,

tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// check-pass
1+
// check-fail
2+
// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom
23
#![feature(transmutability)]
34

45
mod assert {
@@ -21,5 +22,5 @@ mod assert {
2122
fn main() {
2223
#[repr(C)] struct A(bool, &'static A);
2324
#[repr(C)] struct B(u8, &'static B);
24-
assert::is_maybe_transmutable::<&'static A, &'static B>();
25+
assert::is_maybe_transmutable::<&'static A, &'static B>(); //~ ERROR overflow evaluating the requirement
2526
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0275]: overflow evaluating the requirement `B: BikeshedIntrinsicFrom<A, assert::Context, Assume { alignment: true, lifetimes: false, safety: true, validity: false }>`
2+
--> $DIR/recursive-wrapper-types-bit-compatible.rs:25:5
3+
|
4+
LL | assert::is_maybe_transmutable::<&'static A, &'static B>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: required by a bound in `is_maybe_transmutable`
8+
--> $DIR/recursive-wrapper-types-bit-compatible.rs:11:14
9+
|
10+
LL | pub fn is_maybe_transmutable<Src, Dst>()
11+
| --------------------- required by a bound in this function
12+
LL | where
13+
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
14+
| ______________^
15+
LL | | Assume {
16+
LL | | alignment: true,
17+
LL | | lifetimes: false,
18+
... |
19+
LL | | }
20+
LL | | }>
21+
| |__________^ required by this bound in `is_maybe_transmutable`
22+
23+
error: aborting due to previous error
24+
25+
For more information about this error, try `rustc --explain E0275`.

tests/ui/transmutability/references/recursive-wrapper-types.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// check-pass
1+
// check-fail
2+
// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom
23
#![feature(transmutability)]
34

45
mod assert {
@@ -21,6 +22,6 @@ mod assert {
2122
fn main() {
2223
#[repr(C)] struct A(&'static B);
2324
#[repr(C)] struct B(&'static A);
24-
assert::is_maybe_transmutable::<&'static A, &'static B>();
25+
assert::is_maybe_transmutable::<&'static A, &'static B>(); //~ overflow evaluating the requirement
2526
assert::is_maybe_transmutable::<&'static B, &'static A>();
2627
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0275]: overflow evaluating the requirement `A: BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: true, lifetimes: false, safety: true, validity: false }>`
2+
--> $DIR/recursive-wrapper-types.rs:25:5
3+
|
4+
LL | assert::is_maybe_transmutable::<&'static A, &'static B>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: required by a bound in `is_maybe_transmutable`
8+
--> $DIR/recursive-wrapper-types.rs:11:14
9+
|
10+
LL | pub fn is_maybe_transmutable<Src, Dst>()
11+
| --------------------- required by a bound in this function
12+
LL | where
13+
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
14+
| ______________^
15+
LL | | Assume {
16+
LL | | alignment: true,
17+
LL | | lifetimes: false,
18+
... |
19+
LL | | }
20+
LL | | }>
21+
| |__________^ required by this bound in `is_maybe_transmutable`
22+
23+
error: aborting due to previous error
24+
25+
For more information about this error, try `rustc --explain E0275`.

0 commit comments

Comments
 (0)