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