]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-11709.rs
Rollup merge of #106043 - c410-f3r:moar-errors, r=petrochenkov
[rust.git] / src / test / ui / issues / issue-11709.rs
1 // run-pass
2 #![allow(dead_code)]
3 // ignore-pretty issue #37199
4
5 // Don't panic on blocks without results
6 // There are several tests in this run-pass that raised
7 // when this bug was opened. The cases where the compiler
8 // panics before the fix have a comment.
9
10 struct S {x:()}
11
12 fn test(slot: &mut Option<Box<dyn FnMut() -> Box<dyn FnMut()>>>) -> () {
13   let a = slot.take();
14   let _a = match a {
15     // `{let .. a(); }` would break
16     Some(mut a) => { let _a = a(); },
17     None => (),
18   };
19 }
20
21 fn not(b: bool) -> bool {
22     if b {
23         !b
24     } else {
25         // `panic!(...)` would break
26         panic!("Break the compiler");
27     }
28 }
29
30 pub fn main() {
31     // {} would break
32     let _r = {};
33     let mut slot = None;
34     // `{ test(...); }` would break
35     let _s : S  = S{ x: { test(&mut slot); } };
36
37     let _b = not(true);
38 }