]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/erroneous-const.rs
Rollup merge of #78083 - ChaiTRex:master, r=m-ou-se
[rust.git] / src / test / ui / consts / const-eval / erroneous-const.rs
1 //! Make sure we error on erroneous consts even if they are unused.
2 #![warn(const_err, unconditional_panic)]
3
4 struct PrintName<T>(T);
5 impl<T> PrintName<T> {
6     const VOID: () = [()][2]; //~WARN any use of this value will cause an error
7     //~^ WARN this operation will panic at runtime
8 }
9
10 const fn no_codegen<T>() {
11     if false {
12         let _ = PrintName::<T>::VOID; //~ERROR could not evaluate static initializer
13     }
14 }
15
16 pub static FOO: () = no_codegen::<i32>();
17
18 fn main() {
19     FOO
20 }