Skip to content

Commit 6189602

Browse files
committed
fix nll reference harder
1 parent 72c235d commit 6189602

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/test/ui/nll/get_default.nll.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ LL | match map.get() {
4141
| --- immutable borrow occurs here
4242
...
4343
LL | map.set(String::new()); // Ideally, this would not error.
44-
| ^^^ mutable borrow occurs here
44+
| ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
4545
|
4646
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1...
4747
--> $DIR/get_default.rs:26:1
@@ -55,14 +55,26 @@ LL | | }
5555
LL | | }
5656
| |_^
5757

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+
5870
error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
5971
--> $DIR/get_default.rs:51:17
6072
|
6173
LL | match map.get() {
6274
| --- immutable borrow occurs here
6375
...
6476
LL | map.set(String::new()); // Ideally, just AST would error here
65-
| ^^^ mutable borrow occurs here
77+
| ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
6678
|
6779
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
6880
--> $DIR/get_default.rs:41:1
@@ -76,18 +88,6 @@ LL | | }
7688
LL | | }
7789
| |_^
7890

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-
9191
error: aborting due to 6 previous errors
9292

9393
For more information about this error, try `rustc --explain E0502`.

0 commit comments

Comments
 (0)