]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/basic_assignment.rs
1bbbe67a12cb8f990274ed7818be22877fba0f56
[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 // ignore-tidy-linelength
9
10 fn main() {
11     let nodrop_x = false;
12     let nodrop_y;
13
14     // Since boolean does not require drop, this can be a simple
15     // assignment:
16     nodrop_y = nodrop_x;
17
18     let drop_x : Option<Box<u32>> = None;
19     let drop_y;
20
21     // Since the type of `drop_y` has drop, we generate a `replace`
22     // terminator:
23     drop_y = drop_x;
24 }
25
26 // END RUST SOURCE
27 // START rustc.main.SimplifyCfg-initial.after.mir
28 //    bb0: {
29 //        StorageLive(_1);
30 //        _1 = const false;
31 //        FakeRead(ForLet, _1);
32 //        StorageLive(_2);
33 //        StorageLive(_3);
34 //        _3 = _1;
35 //        _2 = move _3;
36 //        StorageDead(_3);
37 //        StorageLive(_4);
38 //        _4 = std::option::Option<std::boxed::Box<u32>>::None;
39 //        FakeRead(ForLet, _4);
40 //        AscribeUserType(_4, o, UserTypeProjection { base: UserType(1), projs: [] });
41 //        StorageLive(_5);
42 //        StorageLive(_6);
43 //        _6 = move _4;
44 //        replace(_5 <- move _6) -> [return: bb2, unwind: bb5];
45 //    }
46 //    ...
47 //    bb2: {
48 //        drop(_6) -> [return: bb6, unwind: bb4];
49 //    }
50 //    ...
51 //    bb5: {
52 //        drop(_6) -> bb4;
53 //    }
54 // END rustc.main.SimplifyCfg-initial.after.mir