1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Tests correct kind-checking of the reason stack closures without the :Copy
12 // bound must be noncopyable. For details see
13 // http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/
16 // This struct is needed to create the
17 // otherwise infinite type of a fn that
18 // accepts itself as argument:
22 fn innocent_looking_victim() {
23 let mut x = Some("hello".to_owned());
24 conspirator(|f, writer| {
31 println!("{:?}", msg);
33 None => fail!("oops"),
39 fn conspirator(f: |&R, bool|) {
41 f(&r, false) //~ ERROR use of moved value
44 fn main() { innocent_looking_victim() }