Skip to content

Commit

Permalink
add test for Inconsistent rustc_transmute::is_transmutable(...) resul…
Browse files Browse the repository at this point in the history
…t, got Yes

Fixes rust-lang#110969
  • Loading branch information
matthiaskrgr committed Apr 27, 2024
1 parent 52ab0b6 commit 1adf750
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ICE Inconsistent rustc_transmute::is_transmutable(...) result, got Yes
// issue: rust-lang/rust#110969
#![feature(adt_const_params, generic_const_exprs, transmutability)]
#![allow(incomplete_features, unstable_features)]

mod assert {
use std::mem::BikeshedIntrinsicFrom;

pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>()
where
Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
//~^ ERROR trait takes at most 2 generic arguments but 3 generic arguments were supplied
{
}
}

fn via_associated_const() {
struct Context;
#[repr(C)]
struct Src;
#[repr(C)]
struct Dst;

trait Trait {
const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
//~^ ERROR mismatched types
//~| ERROR `Src` cannot be safely transmuted into `Dst`
//~| ERROR mismatched types
}
}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0107]: trait takes at most 2 generic arguments but 3 generic arguments were supplied
--> $DIR/transmutable-ice-110969.rs:11:14
|
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
| ^^^^^^^^^^^^^^^^^^^^^ ------ help: remove this generic argument
| |
| expected at most 2 generic arguments

error[E0308]: mismatched types
--> $DIR/transmutable-ice-110969.rs:25:74
|
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
| ^^ expected `Assume`, found `()`

error[E0277]: `Src` cannot be safely transmuted into `Dst`
--> $DIR/transmutable-ice-110969.rs:25:60
|
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
| ^^^ `Dst` may carry safety invariants
|
note: required by a bound in `is_transmutable`
--> $DIR/transmutable-ice-110969.rs:11:14
|
LL | pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>()
| --------------- required by a bound in this function
LL | where
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`

error[E0308]: mismatched types
--> $DIR/transmutable-ice-110969.rs:25:29
|
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0107, E0277, E0308.
For more information about an error, try `rustc --explain E0107`.

0 comments on commit 1adf750

Please sign in to comment.