]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/box_expr.rs
ci: Start running wasm32 tests on Travis
[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 // ignore-wasm32-bare compiled with panic=abort by default
12
13 #![feature(box_syntax)]
14
15 fn main() {
16     let x = box S::new();
17     drop(x);
18 }
19
20 struct S;
21
22 impl S {
23     fn new() -> Self { S }
24 }
25
26 impl Drop for S {
27     fn drop(&mut self) {
28         println!("splat!");
29     }
30 }
31
32 // END RUST SOURCE
33 // START rustc.main.ElaborateDrops.before.mir
34 //     let mut _0: ();
35 //     scope 1 {
36 //         let _1: std::boxed::Box<S>;
37 //     }
38 //     ...
39 //     let mut _2: std::boxed::Box<S>;
40 //     let mut _3: ();
41 //     let mut _4: std::boxed::Box<S>;
42 //
43 //     bb0: {
44 //         StorageLive(_1);
45 //         StorageLive(_2);
46 //         _2 = Box(S);
47 //         (*_2) = const S::new() -> [return: bb1, unwind: bb3];
48 //     }
49 //
50 //     bb1: {
51 //         _1 = move _2;
52 //         drop(_2) -> bb4;
53 //     }
54 //
55 //     bb2: {
56 //         resume;
57 //     }
58 //
59 //     bb3: {
60 //         drop(_2) -> bb2;
61 //     }
62 //
63 //     bb4: {
64 //         StorageDead(_2);
65 //         StorageLive(_4);
66 //         _4 = move _1;
67 //         _3 = const std::mem::drop(move _4) -> [return: bb5, unwind: bb7];
68 //     }
69 //
70 //     bb5: {
71 //         drop(_4) -> [return: bb8, unwind: bb6];
72 //     }
73 //
74 //     bb6: {
75 //         drop(_1) -> bb2;
76 //     }
77 //
78 //     bb7: {
79 //         drop(_4) -> bb6;
80 //     }
81 //
82 //     bb8: {
83 //         StorageDead(_4);
84 //         _0 = ();
85 //         drop(_1) -> bb9;
86 //     }
87 //
88 //     bb9: {
89 //         StorageDead(_1);
90 //         return;
91 //     }
92 // }
93 // END rustc.main.ElaborateDrops.before.mir