Skip to content

Commit

Permalink
Auto merge of #1504 - RalfJung:ill-formed-const, r=RalfJung
Browse files Browse the repository at this point in the history
add test for unused ill-formed constant

Once rust-lang/rust#75339 lands, this test should pass.

Fixes #1382.
  • Loading branch information
bors committed Aug 13, 2020
2 parents a44bb29 + 925d607 commit 1bfb26d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c94ed5ca91f1363b66970ce2cbd6e2773e3cb1d3
814bc4fe9364865bfaa94d7825b8eabc11245c7c
2 changes: 1 addition & 1 deletion src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

Expand Down
19 changes: 19 additions & 0 deletions tests/compile-fail/erroneous_const.rs
Original file line number Diff line number Diff line change
@@ -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>();
}

0 comments on commit 1bfb26d

Please sign in to comment.