@@ -4,14 +4,14 @@ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as imm
4
4
LL | match map.get() {
5
5
| --- immutable borrow occurs here
6
6
...
7
- LL | map.set(String::new()); // Just AST errors here
7
+ LL | map.set(String::new()); // Ideally, this would not error.
8
8
| ^^^ mutable borrow occurs here
9
9
...
10
10
LL | }
11
11
| - immutable borrow ends here
12
12
13
13
error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
14
- --> $DIR/get_default.rs:44 :17
14
+ --> $DIR/get_default.rs:45 :17
15
15
|
16
16
LL | match map.get() {
17
17
| --- immutable borrow occurs here
@@ -23,29 +23,71 @@ LL | }
23
23
| - immutable borrow ends here
24
24
25
25
error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
26
- --> $DIR/get_default.rs:50 :17
26
+ --> $DIR/get_default.rs:51 :17
27
27
|
28
28
LL | match map.get() {
29
29
| --- immutable borrow occurs here
30
30
...
31
- LL | map.set(String::new()); // Just AST errors here
31
+ LL | map.set(String::new()); // Ideally, just AST would error here
32
32
| ^^^ mutable borrow occurs here
33
33
...
34
34
LL | }
35
35
| - immutable borrow ends here
36
36
37
37
error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
38
- --> $DIR/get_default.rs:44:17
38
+ --> $DIR/get_default.rs:33:17
39
+ |
40
+ LL | match map.get() {
41
+ | --- immutable borrow occurs here
42
+ ...
43
+ LL | map.set(String::new()); // Ideally, this would not error.
44
+ | ^^^ mutable borrow occurs here
45
+ |
46
+ note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...
47
+ --> $DIR/get_default.rs:26:1
48
+ |
49
+ LL | / fn ok(map: &mut Map) -> &String {
50
+ LL | | loop {
51
+ LL | | match map.get() {
52
+ LL | | Some(v) => {
53
+ ... |
54
+ LL | | }
55
+ LL | | }
56
+ | |_^
57
+
58
+ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
59
+ --> $DIR/get_default.rs:51:17
60
+ |
61
+ LL | match map.get() {
62
+ | --- immutable borrow occurs here
63
+ ...
64
+ LL | map.set(String::new()); // Ideally, just AST would error here
65
+ | ^^^ mutable borrow occurs here
66
+ |
67
+ note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
68
+ --> $DIR/get_default.rs:41:1
69
+ |
70
+ LL | / fn err(map: &mut Map) -> &String {
71
+ LL | | loop {
72
+ LL | | match map.get() {
73
+ LL | | Some(v) => {
74
+ ... |
75
+ LL | | }
76
+ LL | | }
77
+ | |_^
78
+
79
+ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
80
+ --> $DIR/get_default.rs:45:17
39
81
|
40
82
LL | match map.get() {
41
83
| --- immutable borrow occurs here
42
84
LL | Some(v) => {
43
85
LL | map.set(String::new()); // Both AST and MIR error here
44
- | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
86
+ | ^^^ mutable borrow occurs here
45
87
...
46
88
LL | return v;
47
89
| - borrow later used here
48
90
49
- error: aborting due to 4 previous errors
91
+ error: aborting due to 6 previous errors
50
92
51
93
For more information about this error, try `rustc --explain E0502`.
0 commit comments