]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/generator-tiny.rs
Add test for unnecessary panic branches
[rust.git] / src / test / mir-opt / generator-tiny.rs
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