fork/rust
git clone https://git.julia.blue/fork/rust
73528e339aa
1.40.0
1error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable 2 --> $DIR/get_default.rs:21:17 3 | 4LL | fn ok(map: &mut Map) -> &String { 5 | - let's call the lifetime of this reference `'1` 6LL | loop { 7LL | match map.get() { 8 | --- immutable borrow occurs here 9LL | Some(v) => { 10LL | return v; 11 | - returning this value requires that `*map` is borrowed for `'1` 12... 13LL | map.set(String::new()); // Ideally, this would not error. 14 | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here 15 16error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable 17 --> $DIR/get_default.rs:32:17 18 | 19LL | fn err(map: &mut Map) -> &String { 20 | - let's call the lifetime of this reference `'1` 21LL | loop { 22LL | match map.get() { 23 | --- immutable borrow occurs here 24LL | Some(v) => { 25LL | map.set(String::new()); // Both AST and MIR error here 26 | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here 27LL | 28LL | return v; 29 | - returning this value requires that `*map` is borrowed for `'1` 30 31error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable 32 --> $DIR/get_default.rs:37:17 33 | 34LL | fn err(map: &mut Map) -> &String { 35 | - let's call the lifetime of this reference `'1` 36LL | loop { 37LL | match map.get() { 38 | --- immutable borrow occurs here 39... 40LL | return v; 41 | - returning this value requires that `*map` is borrowed for `'1` 42... 43LL | map.set(String::new()); // Ideally, just AST would error here 44 | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here 45 46error: aborting due to 3 previous errors 47 48For more information about this error, try `rustc --explain E0502`.