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