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