]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/box_expr.rs
Rollup merge of #66013 - nnethercote:avoid-hashing-twice-in-get_query, r=Zoxc
[rust.git] / src / test / mir-opt / box_expr.rs
1 // ignore-wasm32-bare compiled with panic=abort by default
2
3 #![feature(box_syntax)]
4
5 fn main() {
6     let x = box S::new();
7     drop(x);
8 }
9
10 struct S;
11
12 impl S {
13     fn new() -> Self { S }
14 }
15
16 impl Drop for S {
17     fn drop(&mut self) {
18         println!("splat!");
19     }
20 }
21
22 // END RUST SOURCE
23 // START rustc.main.ElaborateDrops.before.mir
24 //     let mut _0: ();
25 //     let _1: std::boxed::Box<S>;
26 //     let mut _2: std::boxed::Box<S>;
27 //     let _3: ();
28 //     let mut _4: std::boxed::Box<S>;
29 //     scope 1 {
30 //     }
31 //     bb0: {
32 //         StorageLive(_1);
33 //         StorageLive(_2);
34 //         _2 = Box(S);
35 //         (*_2) = const S::new() -> [return: bb2, unwind: bb3];
36 //     }
37 //
38 //     bb1 (cleanup): {
39 //         resume;
40 //     }
41 //
42 //     bb2: {
43 //         _1 = move _2;
44 //         drop(_2) -> bb4;
45 //     }
46 //
47 //     bb3 (cleanup): {
48 //         drop(_2) -> bb1;
49 //     }
50 //
51 //     bb4: {
52 //         StorageDead(_2);
53 //         StorageLive(_3);
54 //         StorageLive(_4);
55 //         _4 = move _1;
56 //         _3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7];
57 //     }
58 //
59 //     bb5: {
60 //         StorageDead(_4);
61 //         StorageDead(_3);
62 //         _0 = ();
63 //         drop(_1) -> bb8;
64 //     }
65 //     bb6 (cleanup): {
66 //         drop(_1) -> bb1;
67 //     }
68 //     bb7 (cleanup): {
69 //         drop(_4) -> bb6;
70 //     }
71 //     bb8: {
72 //         StorageDead(_1);
73 //         return;
74 //     }
75 // }
76 // END rustc.main.ElaborateDrops.before.mir