Skip to content

Commit 2cbccce

Browse files
Add test for unnecessary panic branches
1 parent 8d9f633 commit 2cbccce

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/test/mir-opt/generator-tiny.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! Tests that generators that cannot return or unwind don't have unnecessary
2+
//! panic branches.
3+
4+
// compile-flags: -Zno-landing-pads
5+
6+
#![feature(generators, generator_trait)]
7+
8+
struct HasDrop;
9+
10+
impl Drop for HasDrop {
11+
fn drop(&mut self) {}
12+
}
13+
14+
fn callee() {}
15+
16+
fn main() {
17+
let _gen = |_x: u8| {
18+
let _d = HasDrop;
19+
loop {
20+
yield;
21+
callee();
22+
}
23+
};
24+
}
25+
26+
// END RUST SOURCE
27+
28+
// START rustc.main-{{closure}}.generator_resume.0.mir
29+
// bb0: {
30+
// ...
31+
// switchInt(move _11) -> [0u32: bb1, 3u32: bb5, otherwise: bb6];
32+
// }
33+
// ...
34+
// END rustc.main-{{closure}}.generator_resume.0.mir

0 commit comments

Comments
 (0)