blob: 19ad6be1c9fa74bdbad1dd978b7df75f15a3dfc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
//@revisions: noopt opt
//@[noopt] compile-flags: -Copt-level=0
//@[opt] compile-flags: -O
//! Make sure we error on erroneous consts even if they are unused.
struct Fail<T>(T);
impl<T> Fail<T> {
const C: () = panic!(); //~ERROR explicit panic
//~| NOTE in this expansion of panic!
}
pub static FOO: () = {
if false {
// This bad constant is only used in dead code in a static initializer... and yet we still
// must make sure that the build fails.
// This relies on const-eval evaluating all `required_consts` of the `static` MIR body.
Fail::<i32>::C; //~ NOTE constant
}
};
fn main() {
FOO
}
|