@@ -11,13 +11,13 @@ struct S(i32);
11
11
fn foo ( test : bool , x : & mut S , y : S , mut z : S ) -> S {
12
12
let ret;
13
13
// `ret` starts off uninitialized
14
- unsafe { rustc_peek ( & ret) ; }
14
+ rustc_peek ( & ret) ;
15
15
16
16
// All function formal parameters start off initialized.
17
17
18
- unsafe { rustc_peek ( & x) } ; //~ ERROR rustc_peek: bit not set
19
- unsafe { rustc_peek ( & y) } ; //~ ERROR rustc_peek: bit not set
20
- unsafe { rustc_peek ( & z) } ; //~ ERROR rustc_peek: bit not set
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
21
21
22
22
ret = if test {
23
23
:: std:: mem:: replace ( x, y)
@@ -27,21 +27,21 @@ fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S {
27
27
} ;
28
28
29
29
// `z` may be uninitialized here.
30
- unsafe { rustc_peek ( & z) ; }
30
+ rustc_peek ( & z) ;
31
31
32
32
// `y` is definitely uninitialized here.
33
- unsafe { rustc_peek ( & y) ; }
33
+ rustc_peek ( & y) ;
34
34
35
35
// `x` is still (definitely) initialized (replace above is a reborrow).
36
- unsafe { rustc_peek ( & x) ; } //~ ERROR rustc_peek: bit not set
36
+ rustc_peek ( & x) ; //~ ERROR rustc_peek: bit not set
37
37
38
38
:: std:: mem:: drop ( x) ;
39
39
40
40
// `x` is *definitely* uninitialized here
41
- unsafe { rustc_peek ( & x) ; }
41
+ rustc_peek ( & x) ;
42
42
43
43
// `ret` is now definitely initialized (via `if` above).
44
- unsafe { rustc_peek ( & ret) ; } //~ ERROR rustc_peek: bit not set
44
+ rustc_peek ( & ret) ; //~ ERROR rustc_peek: bit not set
45
45
46
46
ret
47
47
}
0 commit comments