]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/get_default.stderr
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[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:23: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:35: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:41: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:23:17
39    |
40 LL | fn ok(map: &mut Map) -> &String {
41    |            - let's call the lifetime of this reference `'1`
42 LL |     loop {
43 LL |         match map.get() {
44    |               --- immutable borrow occurs here
45 LL |             Some(v) => {
46 LL |                 return v;
47    |                        - returning this value requires that `*map` is borrowed for `'1`
48 ...
49 LL |                 map.set(String::new()); // Ideally, this would not error.
50    |                 ^^^ mutable borrow occurs here
51
52 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
53   --> $DIR/get_default.rs:35:17
54    |
55 LL | fn err(map: &mut Map) -> &String {
56    |             - let's call the lifetime of this reference `'1`
57 LL |     loop {
58 LL |         match map.get() {
59    |               --- immutable borrow occurs here
60 LL |             Some(v) => {
61 LL |                 map.set(String::new()); // Both AST and MIR error here
62    |                 ^^^ mutable borrow occurs here
63 ...
64 LL |                 return v;
65    |                        - returning this value requires that `*map` is borrowed for `'1`
66
67 error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
68   --> $DIR/get_default.rs:41:17
69    |
70 LL | fn err(map: &mut Map) -> &String {
71    |             - let's call the lifetime of this reference `'1`
72 LL |     loop {
73 LL |         match map.get() {
74    |               --- immutable borrow occurs here
75 ...
76 LL |                 return v;
77    |                        - returning this value requires that `*map` is borrowed for `'1`
78 ...
79 LL |                 map.set(String::new()); // Ideally, just AST would error here
80    |                 ^^^ mutable borrow occurs here
81
82 error: aborting due to 6 previous errors
83
84 For more information about this error, try `rustc --explain E0502`.