]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/issue-41888.rs
Rollup merge of #44378 - frehberg:rustdoc, r=dtolnay
[rust.git] / src / test / mir-opt / issue-41888.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 clear the "ADT master drop flag" even when there are
12 // no fields to be dropped.
13
14 fn main() {
15     let e;
16     if cond() {
17         e = E::F(K);
18         if let E::F(_k) = e {
19             // older versions of rustc used to not clear the
20             // drop flag for `e` in this path.
21         }
22     }
23 }
24
25 fn cond() -> bool { false }
26
27 struct K;
28
29 enum E {
30     F(K),
31     G(Box<E>)
32 }
33
34 // END RUST SOURCE
35 // fn main() -> () {
36 //     let mut _0: ();
37 //     scope 1 {
38 //         let _1: E; // `e`
39 //         scope 2 {
40 //             let _6: K;
41 //         }
42 //     }
43 //     let mut _2: bool;
44 //     let mut _3: ();
45 //     let mut _4: E;
46 //     let mut _5: K;
47 //     let mut _7: isize;
48 //     let mut _8: bool; // drop flag for `e`
49 //     let mut _9: bool;
50 //     let mut _10: bool;
51 //     let mut _11: isize;
52 //     let mut _12: isize;
53 //
54 //     bb0: {
55 //         _8 = const false;
56 //         _10 = const false;
57 //         _9 = const false;
58 //         StorageLive(_1);
59 //         StorageLive(_2);
60 //         _2 = const cond() -> [return: bb3, unwind: bb2];
61 //     }
62 //
63 //     bb1: {
64 //         resume;
65 //     }
66 //
67 //     bb2: {
68 //         goto -> bb1;
69 //     }
70 //
71 //     bb3: {
72 //         switchInt(_2) -> [0u8: bb5, otherwise: bb4];
73 //     }
74 //
75 //     bb4: {
76 //         StorageLive(_4);
77 //         StorageLive(_5);
78 //         _5 = K::{{constructor}};
79 //         _4 = E::F(_5,);
80 //         StorageDead(_5);
81 //         goto -> bb15;
82 //     }
83 //
84 //     bb5: {
85 //         _0 = ();
86 //         goto -> bb12;
87 //     }
88 //
89 //     bb6: {
90 //         goto -> bb2;
91 //     }
92 //
93 //     bb7: {
94 //         goto -> bb8;
95 //     }
96 //
97 //     bb8: {
98 //         StorageDead(_4);
99 //         _7 = discriminant(_1);
100 //         switchInt(_7) -> [0isize: bb10, otherwise: bb9];
101 //     }
102 //
103 //     bb9: {
104 //         _0 = ();
105 //         goto -> bb11;
106 //     }
107 //
108 //     bb10: {
109 //         StorageLive(_6);
110 //         _10 = const false;
111 //         _6 = ((_1 as F).0: K);
112 //         _0 = ();
113 //         goto -> bb11;
114 //     }
115 //
116 //     bb11: {
117 //         StorageDead(_6);
118 //         goto -> bb12;
119 //     }
120 //
121 //     bb12: {
122 //         StorageDead(_2);
123 //         goto -> bb22;
124 //     }
125 //
126 //     bb13: {
127 //         StorageDead(_1);
128 //         return;
129 //     }
130 //
131 //     bb14: {
132 //         _8 = const true;
133 //         _9 = const true;
134 //         _10 = const true;
135 //         _1 = _4;
136 //         goto -> bb6;
137 //     }
138 //
139 //     bb15: {
140 //         _8 = const true;
141 //         _9 = const true;
142 //         _10 = const true;
143 //         _1 = _4;
144 //         goto -> bb7;
145 //     }
146 //
147 //     bb16: {
148 //         _8 = const false; // clear the drop flag - must always be reached
149 //         goto -> bb13;
150 //     }
151 //
152 //     bb17: {
153 //         _8 = const false;
154 //         goto -> bb1;
155 //     }
156 //
157 //     bb18: {
158 //         goto -> bb17;
159 //     }
160 //
161 //     bb19: {
162 //         drop(_1) -> [return: bb16, unwind: bb17];
163 //     }
164 //
165 //     bb20: {
166 //         drop(_1) -> bb17;
167 //     }
168 //
169 //     bb21: {
170 //         _11 = discriminant(_1);
171 //         switchInt(_11) -> [0isize: bb16, otherwise: bb19];
172 //     }
173 //
174 //     bb22: {
175 //         switchInt(_8) -> [0u8: bb16, otherwise: bb21];
176 //     }
177 //
178 //     bb23: {
179 //         _12 = discriminant(_1);
180 //         switchInt(_12) -> [0isize: bb18, otherwise: bb20];
181 //     }
182 //
183 //     bb24: {
184 //         switchInt(_8) -> [0u8: bb17, otherwise: bb23];
185 //     }
186 // }