]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/region-ends-after-if-condition.nll.stderr
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / nll / region-ends-after-if-condition.nll.stderr
1 error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast)
2   --> $DIR/region-ends-after-if-condition.rs:29:9
3    |
4 LL |     let value = &my_struct.field;
5    |                  --------------- immutable borrow occurs here
6 LL |     if value.is_empty() {
7 LL |         my_struct.field.push_str("Hello, world!");
8    |         ^^^^^^^^^^^^^^^ mutable borrow occurs here
9 ...
10 LL | }
11    | - immutable borrow ends here
12
13 error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast)
14   --> $DIR/region-ends-after-if-condition.rs:39:9
15    |
16 LL |     let value = &my_struct.field;
17    |                  --------------- immutable borrow occurs here
18 LL |     if value.is_empty() {
19 LL |         my_struct.field.push_str("Hello, world!");
20    |         ^^^^^^^^^^^^^^^ mutable borrow occurs here
21 ...
22 LL | }
23    | - immutable borrow ends here
24
25 error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Mir)
26   --> $DIR/region-ends-after-if-condition.rs:39:9
27    |
28 LL |     let value = &my_struct.field;
29    |                 ---------------- immutable borrow occurs here
30 LL |     if value.is_empty() {
31 LL |         my_struct.field.push_str("Hello, world!");
32    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
33 ...
34 LL |     drop(value);
35    |          ----- borrow later used here
36
37 error: aborting due to 3 previous errors
38
39 For more information about this error, try `rustc --explain E0502`.