File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( core_intrinsics, rustc_attrs) ]
2
+
3
+ use std:: intrinsics:: rustc_peek;
4
+
5
+ #[ rustc_mir( rustc_peek_liveness, stop_after_dataflow) ]
6
+ fn foo ( ) {
7
+ {
8
+ let mut x: ( i32 , i32 ) = ( 42 , 0 ) ;
9
+
10
+ // Assignment to a projection does not cause `x` to become live
11
+ unsafe { rustc_peek ( x) ; } //~ ERROR bit not set
12
+ x. 1 = 42 ;
13
+
14
+ x = ( 0 , 42 ) ;
15
+
16
+ // ...but a read from a projection does.
17
+ unsafe { rustc_peek ( x) ; }
18
+ println ! ( "{}" , x. 1 ) ;
19
+ }
20
+
21
+ {
22
+ let mut x = 42 ;
23
+
24
+ // Derefs are treated like a read of a local even if they are on the RHS of an assignment.
25
+ let p = & mut x;
26
+ unsafe { rustc_peek ( & p) ; }
27
+ * p = 24 ;
28
+ unsafe { rustc_peek ( & p) ; } //~ ERROR bit not set
29
+ }
30
+ }
31
+
32
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: rustc_peek: bit not set
2
+ --> $DIR/liveness-projection.rs:11:18
3
+ |
4
+ LL | unsafe { rustc_peek(x); }
5
+ | ^^^^^^^^^^^^^
6
+
7
+ error: rustc_peek: bit not set
8
+ --> $DIR/liveness-projection.rs:28:18
9
+ |
10
+ LL | unsafe { rustc_peek(&p); }
11
+ | ^^^^^^^^^^^^^^
12
+
13
+ error: stop_after_dataflow ended compilation
14
+
15
+ error: aborting due to 3 previous errors
16
+
You can’t perform that action at this time.
0 commit comments