forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#136730 - lukas-code:trans-ice, r=jswrenn
transmutability: fix ICE when passing wrong ADT to ASSUME - Remove an incorrect assert that the `ASSUME` parameter has the type `Assume` and delay a bug instead. - Since we checked the type of `ASSUME` is `Assume` (an ADT), its valtree must be a branch, so we can just unwrap it. r? ```@jswrenn```
- Loading branch information
Showing
3 changed files
with
45 additions
and
18 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.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,20 @@ | ||
//! Test that we don't ICE when passing the wrong ADT to ASSUME. | ||
#![feature(adt_const_params)] | ||
#![feature(transmutability)] | ||
|
||
use std::marker::ConstParamTy; | ||
use std::mem::TransmuteFrom; | ||
|
||
#[derive(ConstParamTy, PartialEq, Eq)] | ||
struct NotAssume; | ||
|
||
fn foo<const ASSUME: NotAssume>() | ||
where | ||
u8: TransmuteFrom<u8, ASSUME>, //~ ERROR the constant `ASSUME` is not of type `Assume` | ||
{ | ||
} | ||
|
||
fn main() { | ||
foo::<{ NotAssume }>(); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.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,11 @@ | ||
error: the constant `ASSUME` is not of type `Assume` | ||
--> $DIR/wrong-adt-assume.rs:14:9 | ||
| | ||
LL | u8: TransmuteFrom<u8, ASSUME>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `NotAssume` | ||
| | ||
note: required by a const generic parameter in `TransmuteFrom` | ||
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL | ||
|
||
error: aborting due to 1 previous error | ||
|