forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for Inconsistent rustc_transmute::is_transmutable(...) resul…
…t, got Yes Fixes rust-lang#110969
- Loading branch information
1 parent
90650b0
commit 0495f8f
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
tests/ui/const-generics/adt_const_params/transmutable-ice-110969.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
39 changes: 39 additions & 0 deletions
39
tests/ui/const-generics/adt_const_params/transmutable-ice-110969.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |