2016-05-06 11:48:48 -05:00
|
|
|
// General test of maybe_uninits state computed by MIR dataflow.
|
|
|
|
|
2016-11-10 11:08:21 -06:00
|
|
|
#![feature(core_intrinsics, rustc_attrs)]
|
2016-05-06 11:48:48 -05:00
|
|
|
|
|
|
|
use std::intrinsics::rustc_peek;
|
|
|
|
use std::mem::{drop, replace};
|
|
|
|
|
|
|
|
struct S(i32);
|
|
|
|
|
2016-05-24 16:08:34 -05:00
|
|
|
#[rustc_mir(rustc_peek_maybe_uninit,stop_after_dataflow)]
|
2016-05-06 11:48:48 -05:00
|
|
|
fn foo(x: &mut S) {
|
|
|
|
// `x` is initialized here, so maybe-uninit bit is 0.
|
|
|
|
|
2020-06-27 04:47:18 -05:00
|
|
|
rustc_peek(&x); //~ ERROR rustc_peek: bit not set
|
2016-05-06 11:48:48 -05:00
|
|
|
|
|
|
|
::std::mem::drop(x);
|
|
|
|
|
|
|
|
// `x` definitely uninitialized here, so maybe-uninit bit is 1.
|
2020-06-27 04:47:18 -05:00
|
|
|
rustc_peek(&x);
|
2016-05-06 11:48:48 -05:00
|
|
|
}
|
|
|
|
fn main() {
|
|
|
|
foo(&mut S(13));
|
|
|
|
foo(&mut S(13));
|
|
|
|
}
|