]> git.proxmox.com Git - rustc.git/blob - tests/ui/mir-dataflow/uninits-2.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / mir-dataflow / uninits-2.rs
1 // General test of maybe_uninits state computed by MIR dataflow.
2
3 #![feature(core_intrinsics, rustc_attrs)]
4
5 use std::intrinsics::rustc_peek;
6 use std::mem::{drop, replace};
7
8 struct S(i32);
9
10 #[rustc_mir(rustc_peek_maybe_uninit,stop_after_dataflow)]
11 fn foo(x: &mut S) {
12 // `x` is initialized here, so maybe-uninit bit is 0.
13
14 rustc_peek(&x); //~ ERROR rustc_peek: bit not set
15
16 ::std::mem::drop(x);
17
18 // `x` definitely uninitialized here, so maybe-uninit bit is 1.
19 rustc_peek(&x);
20 }
21 fn main() {
22 foo(&mut S(13));
23 foo(&mut S(13));
24 }