]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/get_default.stderr
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
[rust.git] / src / test / ui / nll / get_default.stderr
1 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
2   --> $DIR/get_default.rs:33:17
3    |
4 LL |         match map.get() {
5    |               --- immutable borrow occurs here
6 ...
7 LL |                 map.set(String::new()); // Ideally, this would not error.
8    |                 ^^^ mutable borrow occurs here
9 ...
10 LL | }
11    | - immutable borrow ends here
12
13 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
14   --> $DIR/get_default.rs:45:17
15    |
16 LL |         match map.get() {
17    |               --- immutable borrow occurs here
18 LL |             Some(v) => {
19 LL |                 map.set(String::new()); // Both AST and MIR error here
20    |                 ^^^ mutable borrow occurs here
21 ...
22 LL | }
23    | - immutable borrow ends here
24
25 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
26   --> $DIR/get_default.rs:51:17
27    |
28 LL |         match map.get() {
29    |               --- immutable borrow occurs here
30 ...
31 LL |                 map.set(String::new()); // Ideally, just AST would error here
32    |                 ^^^ mutable borrow occurs here
33 ...
34 LL | }
35    | - immutable borrow ends here
36
37 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
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: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
70 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
71   --> $DIR/get_default.rs:51:17
72    |
73 LL |         match map.get() {
74    |               --- immutable borrow occurs here
75 ...
76 LL |                 map.set(String::new()); // Ideally, just AST would error here
77    |                 ^^^ mutable borrow occurs here
78    |
79 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
80   --> $DIR/get_default.rs:41:1
81    |
82 LL | / fn err(map: &mut Map) -> &String {
83 LL | |     loop {
84 LL | |         match map.get() {
85 LL | |             Some(v) => {
86 ...  |
87 LL | |     }
88 LL | | }
89    | |_^
90
91 error: aborting due to 6 previous errors
92
93 For more information about this error, try `rustc --explain E0502`.