]> git.proxmox.com Git - rustc.git/blame - tests/ui/consts/const-eval/erroneous-const.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / consts / const-eval / erroneous-const.rs
CommitLineData
3dfed10e 1//! Make sure we error on erroneous consts even if they are unused.
2b03887a 2#![allow(unconditional_panic)]
3dfed10e
XL
3
4struct PrintName<T>(T);
5impl<T> PrintName<T> {
2b03887a 6 const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::<i32>::VOID` failed
3dfed10e
XL
7}
8
9const 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 17pub static FOO: () = no_codegen::<i32>();
3dfed10e
XL
18
19fn main() {
20 FOO
21}