Skip to content

Commit 1bfb26d

Browse files
committed
Auto merge of #1504 - RalfJung:ill-formed-const, r=RalfJung
add test for unused ill-formed constant Once rust-lang/rust#75339 lands, this test should pass. Fixes #1382.
2 parents a44bb29 + 925d607 commit 1bfb26d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c94ed5ca91f1363b66970ce2cbd6e2773e3cb1d3
1+
814bc4fe9364865bfaa94d7825b8eabc11245c7c

src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
227227
TopFrameInfo {
228228
stack_size: this.active_thread_stack().len(),
229229
instance: Some(frame.instance),
230-
span: frame.current_source_info().map_or(DUMMY_SP, |si| si.span),
230+
span: frame.current_span(),
231231
}
232232
}
233233

tests/compile-fail/erroneous_const.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Make sure we detect erroneous constants post-monomorphization even when they are unused.
2+
//! (https://github.com/rust-lang/miri/issues/1382)
3+
#![feature(const_panic)]
4+
#![feature(never_type)]
5+
#![warn(warnings, const_err)]
6+
7+
struct PrintName<T>(T);
8+
impl<T> PrintName<T> {
9+
const VOID: ! = panic!(); //~WARN any use of this value will cause an error
10+
}
11+
12+
fn no_codegen<T>() {
13+
if false {
14+
let _ = PrintName::<T>::VOID; //~ERROR referenced constant has errors
15+
}
16+
}
17+
fn main() {
18+
no_codegen::<i32>();
19+
}

0 commit comments

Comments
 (0)