2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2014-02-07 20:00:31 +00:00
|
|
|
|
2014-10-09 19:17:22 +00:00
|
|
|
// Don't panic on blocks without results
|
2014-02-07 20:00:31 +00:00
|
|
|
// There are several tests in this run-pass that raised
|
2014-08-01 23:42:13 +00:00
|
|
|
// when this bug was opened. The cases where the compiler
|
2014-10-09 19:17:22 +00:00
|
|
|
// panics before the fix have a comment.
|
2014-02-07 20:00:31 +00:00
|
|
|
|
2014-11-26 13:12:18 +00:00
|
|
|
struct S {x:()}
|
2014-02-07 20:00:31 +00:00
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
fn test(slot: &mut Option<Box<dyn FnMut() -> Box<dyn FnMut()>>>) -> () {
|
2014-02-07 20:00:31 +00:00
|
|
|
let a = slot.take();
|
2023-06-12 08:55:36 +00:00
|
|
|
let _a: () = match a {
|
2014-02-07 20:00:31 +00:00
|
|
|
// `{let .. a(); }` would break
|
2015-08-12 00:27:05 +00:00
|
|
|
Some(mut a) => { let _a = a(); },
|
2014-02-07 20:00:31 +00:00
|
|
|
None => (),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn not(b: bool) -> bool {
|
|
|
|
if b {
|
|
|
|
!b
|
|
|
|
} else {
|
2014-10-09 19:17:22 +00:00
|
|
|
// `panic!(...)` would break
|
|
|
|
panic!("Break the compiler");
|
2014-02-07 20:00:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
// {} would break
|
2023-06-12 08:55:36 +00:00
|
|
|
let _r: () = {};
|
2014-02-07 20:00:31 +00:00
|
|
|
let mut slot = None;
|
|
|
|
// `{ test(...); }` would break
|
2014-11-26 13:12:18 +00:00
|
|
|
let _s : S = S{ x: { test(&mut slot); } };
|
2014-02-07 20:00:31 +00:00
|
|
|
|
|
|
|
let _b = not(true);
|
|
|
|
}
|