]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-closures-use-after-free.stderr
Auto merge of #95474 - oli-obk:tait_ub, r=jackh726
[rust.git] / src / test / ui / borrowck / borrowck-closures-use-after-free.stderr
1 error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable
2   --> $DIR/borrowck-closures-use-after-free.rs:22:8
3    |
4 LL |   let mut test = |foo: &Foo| {
5    |                  ----------- mutable borrow occurs here
6 LL |     ptr = Box::new(Foo { x: ptr.x + 1 });
7    |     --- first borrow occurs due to use of `ptr` in closure
8 LL |   };
9 LL |   test(&*ptr);
10    |   ---- ^^^^^ immutable borrow occurs here
11    |   |
12    |   mutable borrow later used by call
13
14 error: aborting due to previous error
15
16 For more information about this error, try `rustc --explain E0502`.