]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/box_expr.rs
Rollup merge of #66377 - XAMPPRocky:relnotes-1.40.0, r=Mark-Simulacrum
[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 //         debug x => _1;
31 //     }
32 //     bb0: {
33 //         StorageLive(_1);
34 //         StorageLive(_2);
35 //         _2 = Box(S);
36 //         (*_2) = const S::new() -> [return: bb2, unwind: bb3];
37 //     }
38 //
39 //     bb1 (cleanup): {
40 //         resume;
41 //     }
42 //
43 //     bb2: {
44 //         _1 = move _2;
45 //         drop(_2) -> bb4;
46 //     }
47 //
48 //     bb3 (cleanup): {
49 //         drop(_2) -> bb1;
50 //     }
51 //
52 //     bb4: {
53 //         StorageDead(_2);
54 //         StorageLive(_3);
55 //         StorageLive(_4);
56 //         _4 = move _1;
57 //         _3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7];
58 //     }
59 //
60 //     bb5: {
61 //         StorageDead(_4);
62 //         StorageDead(_3);
63 //         _0 = ();
64 //         drop(_1) -> bb8;
65 //     }
66 //     bb6 (cleanup): {
67 //         drop(_1) -> bb1;
68 //     }
69 //     bb7 (cleanup): {
70 //         drop(_4) -> bb6;
71 //     }
72 //     bb8: {
73 //         StorageDead(_1);
74 //         return;
75 //     }
76 // }
77 // END rustc.main.ElaborateDrops.before.mir