rust/tests/compile-fail/erroneous_const.rs
Noah Lev 9af75a824f rustup
Update to the `HEAD` commit of rust-lang/rust and fix test failure.
2021-10-05 13:13:06 -07:00

21 lines
577 B
Rust

//! Make sure we detect erroneous constants post-monomorphization even when they are unused.
//! (https://github.com/rust-lang/miri/issues/1382)
// Inlining changes the error location
// compile-flags: -Zmir-opt-level=0
#![feature(never_type)]
#![warn(warnings, const_err)]
struct PrintName<T>(T);
impl<T> PrintName<T> {
const VOID: ! = panic!(); //~ERROR evaluation of `PrintName::<i32>::VOID` failed
}
fn no_codegen<T>() {
if false {
let _ = PrintName::<T>::VOID; //~ERROR error occurred: encountered constant
}
}
fn main() {
no_codegen::<i32>();
}