]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/box_expr.rs
Fix various nll unused mut errors
[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 //     }
37 //     scope 2 {
38 //         let _1: std::boxed::Box<S>;
39 //     }
40 //     let mut _2: std::boxed::Box<S>;
41 //     let mut _3: ();
42 //     let mut _4: std::boxed::Box<S>;
43 //
44 //     bb0: {
45 //         StorageLive(_1);
46 //         StorageLive(_2);
47 //         _2 = Box(S);
48 //         (*_2) = const S::new() -> [return: bb2, unwind: bb3];
49 //     }
50 //
51 //     bb1: {
52 //         resume;
53 //     }
54 //
55 //     bb2: {
56 //         _1 = move _2;
57 //         drop(_2) -> bb4;
58 //     }
59 //
60 //     bb3: {
61 //         drop(_2) -> bb1;
62 //     }
63 //
64 //     bb4: {
65 //         StorageDead(_2);
66 //         StorageLive(_4);
67 //         _4 = move _1;
68 //         _3 = const std::mem::drop(move _4) -> [return: bb5, unwind: bb7];
69 //     }
70 //
71 //     bb5: {
72 //         drop(_4) -> [return: bb8, unwind: bb6];
73 //     }
74 //
75 //     bb6: {
76 //         drop(_1) -> bb1;
77 //     }
78 //
79 //     bb7: {
80 //         drop(_4) -> bb6;
81 //     }
82 //
83 //     bb8: {
84 //         StorageDead(_4);
85 //         _0 = ();
86 //         drop(_1) -> bb9;
87 //     }
88 //
89 //     bb9: {
90 //         StorageDead(_1);
91 //         return;
92 //     }
93 // }
94 // END rustc.main.ElaborateDrops.before.mir