@@ -41,7 +41,7 @@ LL | match map.get() {
41
41
| --- immutable borrow occurs here
42
42
...
43
43
LL | map.set(String::new()); // Ideally, this would not error.
44
- | ^^^ mutable borrow occurs here
44
+ | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
45
45
|
46
46
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...
47
47
--> $DIR/get_default.rs:26:1
@@ -55,14 +55,26 @@ LL | | }
55
55
LL | | }
56
56
| |_^
57
57
58
+ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
59
+ --> $DIR/get_default.rs:45:17
60
+ |
61
+ LL | match map.get() {
62
+ | --- immutable borrow occurs here
63
+ LL | Some(v) => {
64
+ LL | map.set(String::new()); // Both AST and MIR error here
65
+ | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
66
+ ...
67
+ LL | return v;
68
+ | - borrow later used here
69
+
58
70
error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
59
71
--> $DIR/get_default.rs:51:17
60
72
|
61
73
LL | match map.get() {
62
74
| --- immutable borrow occurs here
63
75
...
64
76
LL | map.set(String::new()); // Ideally, just AST would error here
65
- | ^^^ mutable borrow occurs here
77
+ | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
66
78
|
67
79
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
68
80
--> $DIR/get_default.rs:41:1
@@ -76,18 +88,6 @@ LL | | }
76
88
LL | | }
77
89
| |_^
78
90
79
- error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
80
- --> $DIR/get_default.rs:45:17
81
- |
82
- LL | match map.get() {
83
- | --- immutable borrow occurs here
84
- LL | Some(v) => {
85
- LL | map.set(String::new()); // Both AST and MIR error here
86
- | ^^^ mutable borrow occurs here
87
- ...
88
- LL | return v;
89
- | - borrow later used here
90
-
91
91
error: aborting due to 6 previous errors
92
92
93
93
For more information about this error, try `rustc --explain E0502`.
0 commit comments