]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/basic_assignment.rs
Render const pointers in MIR more compactly
[rust.git] / src / test / mir-opt / basic_assignment.rs
1 // this tests move up progration, which is not yet implemented
2
3 // Check codegen for assignments (`a = b`) where the left-hand-side is
4 // not yet initialized. Assignments tend to be absent in simple code,
5 // so subtle breakage in them can leave a quite hard-to-find trail of
6 // destruction.
7
8 fn main() {
9     let nodrop_x = false;
10     let nodrop_y;
11
12     // Since boolean does not require drop, this can be a simple
13     // assignment:
14     nodrop_y = nodrop_x;
15
16     let drop_x : Option<Box<u32>> = None;
17     let drop_y;
18
19     // Since the type of `drop_y` has drop, we generate a `replace`
20     // terminator:
21     drop_y = drop_x;
22 }
23
24 // END RUST SOURCE
25 // START rustc.main.SimplifyCfg-initial.after.mir
26 //    bb0: {
27 //        StorageLive(_1);
28 //        _1 = const false;
29 //        FakeRead(ForLet, _1);
30 //        StorageLive(_2);
31 //        StorageLive(_3);
32 //        _3 = _1;
33 //        _2 = move _3;
34 //        StorageDead(_3);
35 //        StorageLive(_4);
36 //        _4 = std::option::Option::<std::boxed::Box<u32>>::None;
37 //        FakeRead(ForLet, _4);
38 //        AscribeUserType(_4, o, UserTypeProjection { base: UserType(1), projs: [] });
39 //        StorageLive(_5);
40 //        StorageLive(_6);
41 //        _6 = move _4;
42 //        replace(_5 <- move _6) -> [return: bb2, unwind: bb5];
43 //    }
44 //    ...
45 //    bb2: {
46 //        drop(_6) -> [return: bb6, unwind: bb4];
47 //    }
48 //    ...
49 //    bb5 (cleanup): {
50 //        drop(_6) -> bb4;
51 //    }
52 // END rustc.main.SimplifyCfg-initial.after.mir