Skip to content

Commit c89665d

Browse files
committed
Add test that free type const value type mismatch does not ICE
1 parent dba1679 commit c89665d

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(min_generic_const_args)]
2+
#![expect(incomplete_features)]
3+
4+
//@ compile-flags: -Zvalidate-mir
5+
6+
type const N: usize = "this isn't a usize";
7+
//~^ ERROR the constant `"this isn't a usize"` is not of type `usize`
8+
9+
fn f() -> [u8; const { N }] {}
10+
//~^ ERROR transmuting from
11+
12+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: the constant `"this isn't a usize"` is not of type `usize`
2+
--> $DIR/type-const-free-value-type-mismatch.rs:6:1
3+
|
4+
LL | type const N: usize = "this isn't a usize";
5+
| ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&'static str`
6+
7+
error[E0080]: transmuting from 16-byte type to 8-byte type: `&str` -> `usize`
8+
--> $DIR/type-const-free-value-type-mismatch.rs:9:24
9+
|
10+
LL | fn f() -> [u8; const { N }] {}
11+
| ^ evaluation of `f::{constant#0}` failed here
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)