diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 5d20cc6ff6ba..2be61c502598 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -182,7 +182,11 @@ pub fn report_error<'tcx, 'mir>( "Undefined Behavior", ResourceExhaustion(_) => "resource exhaustion", - InvalidProgram(InvalidProgramInfo::AlreadyReported(_) | InvalidProgramInfo::Layout(..)) => + InvalidProgram( + InvalidProgramInfo::AlreadyReported(_) | + InvalidProgramInfo::Layout(..) | + InvalidProgramInfo::ReferencedConstant + ) => "post-monomorphization error", kind => bug!("This error should be impossible in Miri: {:?}", kind), diff --git a/tests/compile-fail/erroneous_const2.rs b/tests/compile-fail/erroneous_const2.rs new file mode 100644 index 000000000000..cdec2ec4f095 --- /dev/null +++ b/tests/compile-fail/erroneous_const2.rs @@ -0,0 +1,12 @@ +const X: u32 = 5; +const Y: u32 = 6; +const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; +//~^ERROR any use of this value +//~|WARN previously accepted + +fn main() { + println!("{}", FOO); //~ERROR post-monomorphization error + //~|ERROR evaluation of constant value failed + //~|ERROR erroneous constant used + //~|WARN previously accepted +}