Auto merge of #1504 - RalfJung:ill-formed-const, r=RalfJung

add test for unused ill-formed constant

Once https://github.com/rust-lang/rust/pull/75339 lands, this test should pass.

Fixes https://github.com/rust-lang/miri/issues/1382.
This commit is contained in:
bors 2020-08-13 06:44:00 +00:00
commit 1bfb26d6ca
3 changed files with 21 additions and 2 deletions

View File

@ -1 +1 @@
c94ed5ca91f1363b66970ce2cbd6e2773e3cb1d3
814bc4fe9364865bfaa94d7825b8eabc11245c7c

View File

@ -227,7 +227,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
TopFrameInfo {
stack_size: this.active_thread_stack().len(),
instance: Some(frame.instance),
span: frame.current_source_info().map_or(DUMMY_SP, |si| si.span),
span: frame.current_span(),
}
}

View File

@ -0,0 +1,19 @@
//! Make sure we detect erroneous constants post-monomorphization even when they are unused.
//! (https://github.com/rust-lang/miri/issues/1382)
#![feature(const_panic)]
#![feature(never_type)]
#![warn(warnings, const_err)]
struct PrintName<T>(T);
impl<T> PrintName<T> {
const VOID: ! = panic!(); //~WARN any use of this value will cause an error
}
fn no_codegen<T>() {
if false {
let _ = PrintName::<T>::VOID; //~ERROR referenced constant has errors
}
}
fn main() {
no_codegen::<i32>();
}