]>
Commit | Line | Data |
---|---|---|
3dfed10e | 1 | //! Make sure we error on erroneous consts even if they are unused. |
2b03887a | 2 | #![allow(unconditional_panic)] |
3dfed10e XL |
3 | |
4 | struct PrintName<T>(T); | |
5 | impl<T> PrintName<T> { | |
2b03887a | 6 | const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::<i32>::VOID` failed |
3dfed10e XL |
7 | } |
8 | ||
9 | const fn no_codegen<T>() { | |
10 | if false { | |
17df50a5 XL |
11 | // This bad constant is only used in dead code in a no-codegen function... and yet we still |
12 | // must make sure that the build fails. | |
487cf647 | 13 | let _ = PrintName::<T>::VOID; //~ constant |
3dfed10e XL |
14 | } |
15 | } | |
16 | ||
fc512014 | 17 | pub static FOO: () = no_codegen::<i32>(); |
3dfed10e XL |
18 | |
19 | fn main() { | |
20 | FOO | |
21 | } |