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