]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/erroneous_const.rs
199439ccbd2e78f5ee9cbf32d6f6baa58c584f6a
[rust.git] / tests / compile-fail / erroneous_const.rs
1 //! Make sure we detect erroneous constants post-monomorphization even when they are unused.
2 //! (https://github.com/rust-lang/miri/issues/1382)
3 // Inlining changes the error location
4 // compile-flags: -Zmir-opt-level=0
5 #![feature(const_panic)]
6 #![feature(never_type)]
7 #![warn(warnings, const_err)]
8
9 struct PrintName<T>(T);
10 impl<T> PrintName<T> {
11     const VOID: ! = panic!(); //~ERROR evaluation of `PrintName::<i32>::VOID` failed
12 }
13
14 fn no_codegen<T>() {
15     if false {
16         let _ = PrintName::<T>::VOID; //~ERROR error occurred: encountered constant
17     }
18 }
19 fn main() {
20     no_codegen::<i32>();
21 }