]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/issue-41110.rs
ci: Start running wasm32 tests on Travis
[rust.git] / src / test / mir-opt / issue-41110.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 // check that we don't emit multiple drop flags when they are not needed.
14
15 fn main() {
16     let x = S.other(S.id());
17 }
18
19 // no_mangle to make sure this gets instantiated even in an executable.
20 #[no_mangle]
21 pub fn test() {
22     let u = S;
23     let mut v = S;
24     drop(v);
25     v = u;
26 }
27
28 struct S;
29 impl Drop for S {
30     fn drop(&mut self) {
31     }
32 }
33
34 impl S {
35     fn id(self) -> Self { self }
36     fn other(self, s: Self) {}
37 }
38
39 // END RUST SOURCE
40 // START rustc.main.ElaborateDrops.after.mir
41 //    let mut _0: ();
42 //    scope 1 {
43 //        let _1: ();
44 //    }
45 //    ...
46 //    let mut _2: S;
47 //    let mut _3: S;
48 //    let mut _4: S;
49 //    let mut _5: bool;
50 //    bb0: {
51 // END rustc.main.ElaborateDrops.after.mir
52 // START rustc.test.ElaborateDrops.after.mir
53 //    let mut _0: ();
54 //    ...
55 //    let _1: S;
56 //    ...
57 //    let mut _2: S;
58 //    ...
59 //    let mut _3: ();
60 //    let mut _4: S;
61 //    let mut _5: S;
62 //    let mut _6: bool;
63 //    bb0: {
64 // END rustc.test.ElaborateDrops.after.mir