]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/issue-41110.rs
Rollup merge of #44378 - frehberg:rustdoc, r=dtolnay
[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 // check that we don't emit multiple drop flags when they are not needed.
12
13 fn main() {
14     let x = S.other(S.id());
15 }
16
17 pub fn test() {
18     let u = S;
19     let mut v = S;
20     drop(v);
21     v = u;
22 }
23
24 struct S;
25 impl Drop for S {
26     fn drop(&mut self) {
27     }
28 }
29
30 impl S {
31     fn id(self) -> Self { self }
32     fn other(self, s: Self) {}
33 }
34
35 // END RUST SOURCE
36 // START rustc.node4.ElaborateDrops.after.mir
37 //    let mut _0: ();
38 //    let _1: ();
39 //    let mut _2: S;
40 //    let mut _3: S;
41 //    let mut _4: S;
42 //    let mut _5: bool;
43 //
44 //    bb0: {
45 // END rustc.node4.ElaborateDrops.after.mir
46 // START rustc.node13.ElaborateDrops.after.mir
47 //    let mut _0: ();
48 //    let _1: S;
49 //    let mut _2: S;
50 //    let mut _3: ();
51 //    let mut _4: S;
52 //    let mut _5: S;
53 //    let mut _6: bool;
54 //
55 //    bb0: {
56 // END rustc.node13.ElaborateDrops.after.mir