]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/box_expr.rs
Rollup merge of #45095 - bluss:discriminant-send-sync, r=alexcrichton
[rust.git] / src / test / mir-opt / box_expr.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(box_syntax)]
12
13 fn main() {
14     let x = box S::new();
15     drop(x);
16 }
17
18 struct S;
19
20 impl S {
21     fn new() -> Self { S }
22 }
23
24 impl Drop for S {
25     fn drop(&mut self) {
26         println!("splat!");
27     }
28 }
29
30 // END RUST SOURCE
31 // START rustc.node4.ElaborateDrops.before.mir
32 //     let mut _0: ();
33 //     let _1: std::boxed::Box<S>;
34 //     let mut _2: std::boxed::Box<S>;
35 //     let mut _3: ();
36 //     let mut _4: std::boxed::Box<S>;
37 //
38 //     bb0: {
39 //         StorageLive(_1);
40 //         StorageLive(_2);
41 //         _2 = Box(S);
42 //         (*_2) = const S::new() -> [return: bb1, unwind: bb3];
43 //     }
44 //
45 //     bb1: {
46 //         _1 = _2;
47 //         drop(_2) -> bb4;
48 //     }
49 //
50 //     bb2: {
51 //         resume;
52 //     }
53 //
54 //     bb3: {
55 //         drop(_2) -> bb2;
56 //     }
57 //
58 //     bb4: {
59 //         StorageDead(_2);
60 //         StorageLive(_4);
61 //         _4 = _1;
62 //         _3 = const std::mem::drop(_4) -> [return: bb5, unwind: bb7];
63 //     }
64 //
65 //     bb5: {
66 //         drop(_4) -> [return: bb8, unwind: bb6];
67 //     }
68 //
69 //     bb6: {
70 //         drop(_1) -> bb2;
71 //     }
72 //
73 //     bb7: {
74 //         drop(_4) -> bb6;
75 //     }
76 //
77 //     bb8: {
78 //         StorageDead(_4);
79 //         _0 = ();
80 //         drop(_1) -> bb9;
81 //     }
82 //
83 //     bb9: {
84 //         StorageDead(_1);
85 //         return;
86 //     }
87 // }
88 // END rustc.node4.ElaborateDrops.before.mir