]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/erroneous-const.rs
Rollup merge of #81676 - jyn514:crate-not-found, r=oli-obk
[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     //~| WARN this was previously accepted by the compiler but is being phased out
9 }
10
11 const fn no_codegen<T>() {
12     if false {
13         let _ = PrintName::<T>::VOID; //~ERROR could not evaluate static initializer
14     }
15 }
16
17 pub static FOO: () = no_codegen::<i32>();
18
19 fn main() {
20     FOO
21 }