mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
add test checking that we do run MIR validation
This commit is contained in:
parent
0f44382bca
commit
5ef38aca35
21
src/tools/miri/tests/panic/mir-validation.rs
Normal file
21
src/tools/miri/tests/panic/mir-validation.rs
Normal file
@ -0,0 +1,21 @@
|
||||
//! Ensure that the MIR validator runs on Miri's input.
|
||||
//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
|
||||
//@normalize-stderr-test: "\n +at [^\n]+" -> ""
|
||||
//@normalize-stderr-test: "\n +\[\.\.\. omitted [0-9]+ frames? \.\.\.\]" -> ""
|
||||
//@normalize-stderr-test: "\n[ =]*note:.*" -> ""
|
||||
#![feature(custom_mir, core_intrinsics)]
|
||||
use core::intrinsics::mir::*;
|
||||
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
pub fn main() {
|
||||
mir! {
|
||||
let x: i32;
|
||||
let tuple: (*mut i32,);
|
||||
{
|
||||
tuple.0 = core::ptr::addr_of_mut!(x);
|
||||
// Deref at the wrong place!
|
||||
*(tuple.0) = 1;
|
||||
Return()
|
||||
}
|
||||
}
|
||||
}
|
21
src/tools/miri/tests/panic/mir-validation.stderr
Normal file
21
src/tools/miri/tests/panic/mir-validation.stderr
Normal file
@ -0,0 +1,21 @@
|
||||
thread 'rustc' panicked at compiler/rustc_const_eval/src/transform/validate.rs:LL:CC:
|
||||
broken MIR in Item(DefId(0:4 ~ mir_validation[fad2]::main)) (after phase change to runtime-optimized) at bb0[1]:
|
||||
(*(_2.0: *mut i32)), has deref at the wrong place
|
||||
stack backtrace:
|
||||
|
||||
error: the compiler unexpectedly panicked. this is a bug.
|
||||
|
||||
|
||||
|
||||
|
||||
query stack during panic:
|
||||
#0 [optimized_mir] optimizing MIR for `main`
|
||||
end of query stack
|
||||
|
||||
Miri caused an ICE during evaluation. Here's the interpreter backtrace at the time of the panic:
|
||||
--> RUSTLIB/core/src/ops/function.rs:LL:CC
|
||||
|
|
||||
LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
|
Loading…
Reference in New Issue
Block a user