2014-02-07 20:00:31 +00:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-02-07 19:08:32 +00:00
|
|
|
// ignore-pretty
|
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
|
|
|
|
2015-06-10 20:33:52 +00:00
|
|
|
#![feature(thunk)]
|
2015-03-06 02:33:58 +00:00
|
|
|
|
2014-11-26 13:12:18 +00:00
|
|
|
use std::thunk::Thunk;
|
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
|
|
|
|
2014-11-26 13:12:18 +00:00
|
|
|
fn test(slot: &mut Option<Thunk<(),Thunk>>) -> () {
|
2014-02-07 20:00:31 +00:00
|
|
|
let a = slot.take();
|
|
|
|
let _a = match a {
|
|
|
|
// `{let .. a(); }` would break
|
2015-04-01 15:12:30 +00:00
|
|
|
Some(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
|
|
|
|
let _r = {};
|
|
|
|
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);
|
|
|
|
}
|