rust/src/test/compile-fail/issue-6762.rs
Alex Crichton 3585c64d09 rustdoc: Change all code-blocks with a script
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g'
    find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g'
    find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
2013-09-25 14:27:42 -07:00

25 lines
405 B
Rust

//xfail-test
// Creating a stack closure which references an owned pointer and then
// transferring ownership of the owned box before invoking the stack
// closure results in a crash.
fn twice(x: ~uint) -> uint
{
*x * 2
}
fn invoke(f : &fn() -> uint)
{
f();
}
fn main()
{
let x : ~uint = ~9;
let sq : &fn() -> uint = || { *x * *x };
twice(x);
invoke(sq);
}