]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/mir-dataflow/uninits-1.rs
1 // General test of maybe_uninits state computed by MIR dataflow.
3 #![feature(core_intrinsics, rustc_attrs)]
5 use std
::intrinsics
::rustc_peek
;
6 use std
::mem
::{drop, replace}
;
10 #[rustc_mir(rustc_peek_maybe_uninit,stop_after_dataflow)]
11 fn foo(test
: bool
, x
: &mut S
, y
: S
, mut z
: S
) -> S
{
13 // `ret` starts off uninitialized
16 // All function formal parameters start off initialized.
18 rustc_peek(&x
); //~ ERROR rustc_peek: bit not set
19 rustc_peek(&y
); //~ ERROR rustc_peek: bit not set
20 rustc_peek(&z
); //~ ERROR rustc_peek: bit not set
23 ::std
::mem
::replace(x
, y
)
29 // `z` may be uninitialized here.
32 // `y` is definitely uninitialized here.
35 // `x` is still (definitely) initialized (replace above is a reborrow).
36 rustc_peek(&x
); //~ ERROR rustc_peek: bit not set
40 // `x` is *definitely* uninitialized here
43 // `ret` is now definitely initialized (via `if` above).
44 rustc_peek(&ret
); //~ ERROR rustc_peek: bit not set
49 foo(true, &mut S(13), S(14), S(15));
50 foo(false, &mut S(13), S(14), S(15));