Skip to content

Commit ff136bd

Browse files
committed
add test for unused ill-formed constant
1 parent 52c7b8e commit ff136bd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/compile-fail/erroneous_const.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Make sure we detect erroneous constants post-monomorphization even when they are unused.
2+
//! (https://github.com/rust-lang/miri/issues/1382)
3+
#![feature(const_panic)]
4+
#![feature(never_type)]
5+
#![warn(const_err)]
6+
7+
struct PrintName<T>(T);
8+
impl<T> PrintName<T> {
9+
const VOID: ! = panic!(); //~WARN any use of this value will cause an error
10+
}
11+
12+
fn no_codegen<T>() {
13+
if false {
14+
let _ = PrintName::<T>::VOID; //~ERROR referenced constant has errors
15+
}
16+
}
17+
fn main() {
18+
no_codegen::<i32>();
19+
}

0 commit comments

Comments
 (0)