Skip to content

Commit 1d1de8b

Browse files
committed
Add test that free type const value type mismatch does not ICE
1 parent 207dbcb commit 1d1de8b

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(min_generic_const_args)]
2+
#![expect(incomplete_features)]
3+
4+
//@ compile-flags: -Zvalidate-mir
5+
//@ normalize-stderr: "\d+-byte" -> "$$BYTE-byte"
6+
7+
type const N: usize = "this isn't a usize";
8+
//~^ ERROR the constant `"this isn't a usize"` is not of type `usize`
9+
10+
fn f() -> [u8; const { N }] {}
11+
//~^ ERROR transmuting from
12+
13+
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:7: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 $BYTE-byte type to $BYTE-byte type: `&str` -> `usize`
8+
--> $DIR/type-const-free-value-type-mismatch.rs:10: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)