Skip to content

Commit 012f9e2

Browse files
committed
add test for Inconsistent rustc_transmute::is_transmutable(...) result, got Yes
Fixes #110969
1 parent c32e2fe commit 012f9e2

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// ICE Inconsistent rustc_transmute::is_transmutable(...) result, got Yes
2+
// issue: rust-lang/rust#110969
3+
#![feature(adt_const_params, generic_const_exprs, transmutability)]
4+
#![allow(incomplete_features, unstable_features)]
5+
6+
mod assert {
7+
use std::mem::BikeshedIntrinsicFrom;
8+
9+
pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>()
10+
where
11+
Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
12+
//~^ ERROR trait takes at most 2 generic arguments but 3 generic arguments were supplied
13+
{
14+
}
15+
}
16+
17+
fn via_associated_const() {
18+
struct Context;
19+
#[repr(C)]
20+
struct Src;
21+
#[repr(C)]
22+
struct Dst;
23+
24+
trait Trait {
25+
const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
26+
//~^ ERROR mismatched types
27+
//~| ERROR `Src` cannot be safely transmuted into `Dst`
28+
//~| ERROR mismatched types
29+
}
30+
}
31+
32+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0107]: trait takes at most 2 generic arguments but 3 generic arguments were supplied
2+
--> $DIR/transmutable-ice-110969.rs:11:14
3+
|
4+
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
5+
| ^^^^^^^^^^^^^^^^^^^^^ ------ help: remove this generic argument
6+
| |
7+
| expected at most 2 generic arguments
8+
9+
error[E0308]: mismatched types
10+
--> $DIR/transmutable-ice-110969.rs:25:74
11+
|
12+
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
13+
| ^^ expected `Assume`, found `()`
14+
15+
error[E0277]: `Src` cannot be safely transmuted into `Dst`
16+
--> $DIR/transmutable-ice-110969.rs:25:60
17+
|
18+
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
19+
| ^^^ `Dst` may carry safety invariants
20+
|
21+
note: required by a bound in `is_transmutable`
22+
--> $DIR/transmutable-ice-110969.rs:11:14
23+
|
24+
LL | pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>()
25+
| --------------- required by a bound in this function
26+
LL | where
27+
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
28+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
29+
30+
error[E0308]: mismatched types
31+
--> $DIR/transmutable-ice-110969.rs:25:29
32+
|
33+
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
35+
36+
error: aborting due to 4 previous errors
37+
38+
Some errors have detailed explanations: E0107, E0277, E0308.
39+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)