1 // Tests that a closure which mutates a local variable
2 // cannot also be supplied a borrowed version of that
3 // variable's contents. Issue #11192.
5 #![feature(box_syntax)]
13 println!("drop {}", self.x);
18 let mut ptr: Box<_> = box Foo { x: 0 };
19 let mut test = |foo: &Foo| {
20 ptr = box Foo { x: ptr.x + 1 };
22 test(&*ptr); //~ ERROR cannot borrow `*ptr`