]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-11192.rs
Rollup merge of #62337 - Mark-Simulacrum:fix-cpu-usage-script, r=alexcrichton
[rust.git] / src / test / ui / issues / issue-11192.rs
1 #![feature(box_syntax)]
2
3 struct Foo {
4     x: isize
5 }
6
7 impl Drop for Foo {
8     fn drop(&mut self) {
9         println!("drop {}", self.x);
10     }
11 }
12
13 fn main() {
14     let mut ptr: Box<_> = box Foo { x: 0 };
15     let mut test = |foo: &Foo| {
16         println!("access {}", foo.x);
17         ptr = box Foo { x: ptr.x + 1 };
18         println!("access {}", foo.x);
19     };
20     test(&*ptr);
21     //~^ ERROR: cannot borrow `*ptr` as immutable
22 }