rust/src/test/run-fail/too-much-recursion-unwinding.rs

46 lines
1.0 KiB
Rust
Raw Normal View History

// Copyright 2012 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.
2012-11-16 11:19:45 -08:00
// xfail-test leaks
// error-pattern:ran out of stack
2013-05-09 02:34:47 +09:00
// Test that the task fails after hitting the recursion limit
2012-11-15 19:50:53 -08:00
// during unwinding
fn recurse() {
info!("don't optimize me out");
recurse();
}
2012-11-15 19:50:53 -08:00
struct r {
recursed: *mut bool,
}
impl Drop for r {
2013-06-20 21:06:13 -04:00
fn drop(&self) {
unsafe {
if !*(self.recursed) {
*(self.recursed) = true;
recurse();
}
2012-11-15 19:50:53 -08:00
}
}
2012-11-15 19:50:53 -08:00
}
fn r(recursed: *mut bool) -> r {
r { recursed: recursed }
}
fn main() {
let mut recursed = false;
let _r = r(&mut recursed);
recurse();
}