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:
commit
1bfb26d6ca
@ -1 +1 @@
|
||||
c94ed5ca91f1363b66970ce2cbd6e2773e3cb1d3
|
||||
814bc4fe9364865bfaa94d7825b8eabc11245c7c
|
||||
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
19
tests/compile-fail/erroneous_const.rs
Normal file
19
tests/compile-fail/erroneous_const.rs
Normal 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>();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user