]> git.lizzy.rs Git - rust.git/blob - tests/ui/mir-dataflow/liveness-projection.rs
Rollup merge of #103236 - tspiteri:redoc-int-adc-sbb, r=m-ou-se
[rust.git] / tests / ui / mir-dataflow / liveness-projection.rs
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 LHS 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() {}