Skip to content

Commit 05ac0f3

Browse files
committed
add test for unused ill-formed constant
also use better span in TopFrameInfo
1 parent 50f3796 commit 05ac0f3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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)