]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-closures-mut-and-imm.stderr
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-closures-mut-and-imm.stderr
1 error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
2   --> $DIR/borrowck-closures-mut-and-imm.rs:17:14
3    |
4 LL |     let c1 = || x = 4;
5    |              -- - first borrow occurs due to use of `x` in closure
6    |              |
7    |              mutable borrow occurs here
8 LL |     let c2 = || x * 5;
9    |              ^^ - second borrow occurs due to use of `x` in closure
10    |              |
11    |              immutable borrow occurs here
12 LL |
13 LL |     drop(c1);
14    |          -- mutable borrow later used here
15
16 error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
17   --> $DIR/borrowck-closures-mut-and-imm.rs:25:14
18    |
19 LL |     let c1 = || set(&mut x);
20    |              --          - first borrow occurs due to use of `x` in closure
21    |              |
22    |              mutable borrow occurs here
23 LL |     let c2 = || get(&x);
24    |              ^^      - second borrow occurs due to use of `x` in closure
25    |              |
26    |              immutable borrow occurs here
27 LL |
28 LL |     drop(c1);
29    |          -- mutable borrow later used here
30
31 error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
32   --> $DIR/borrowck-closures-mut-and-imm.rs:33:14
33    |
34 LL |     let c1 = || set(&mut x);
35    |              --          - first borrow occurs due to use of `x` in closure
36    |              |
37    |              mutable borrow occurs here
38 LL |     let c2 = || x * 5;
39    |              ^^ - second borrow occurs due to use of `x` in closure
40    |              |
41    |              immutable borrow occurs here
42 LL |
43 LL |     drop(c1);
44    |          -- mutable borrow later used here
45
46 error[E0506]: cannot assign to `x` because it is borrowed
47   --> $DIR/borrowck-closures-mut-and-imm.rs:41:5
48    |
49 LL |     let c2 = || x * 5;
50    |              -- - borrow occurs due to use in closure
51    |              |
52    |              borrow of `x` occurs here
53 LL |     x = 5;
54    |     ^^^^^ assignment to borrowed `x` occurs here
55 LL |
56 LL |     drop(c2);
57    |          -- borrow later used here
58
59 error[E0506]: cannot assign to `x` because it is borrowed
60   --> $DIR/borrowck-closures-mut-and-imm.rs:49:5
61    |
62 LL |     let c1 = || get(&x);
63    |              --      - borrow occurs due to use in closure
64    |              |
65    |              borrow of `x` occurs here
66 LL |     x = 5;
67    |     ^^^^^ assignment to borrowed `x` occurs here
68 LL |
69 LL |     drop(c1);
70    |          -- borrow later used here
71
72 error[E0506]: cannot assign to `*x` because it is borrowed
73   --> $DIR/borrowck-closures-mut-and-imm.rs:57:5
74    |
75 LL |     let c1 = || get(&*x);
76    |              --      -- borrow occurs due to use in closure
77    |              |
78    |              borrow of `*x` occurs here
79 LL |     *x = 5;
80    |     ^^^^^^ assignment to borrowed `*x` occurs here
81 LL |
82 LL |     drop(c1);
83    |          -- borrow later used here
84
85 error[E0506]: cannot assign to `*x.f` because it is borrowed
86   --> $DIR/borrowck-closures-mut-and-imm.rs:69:5
87    |
88 LL |     let c1 = || get(&*x.f);
89    |              --      ---- borrow occurs due to use in closure
90    |              |
91    |              borrow of `*x.f` occurs here
92 LL |     *x.f = 5;
93    |     ^^^^^^^^ assignment to borrowed `*x.f` occurs here
94 LL |
95 LL |     drop(c1);
96    |          -- borrow later used here
97
98 error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
99   --> $DIR/borrowck-closures-mut-and-imm.rs:81:14
100    |
101 LL |     let c1 = || get(&*x.f);
102    |              --      ---- first borrow occurs due to use of `x` in closure
103    |              |
104    |              immutable borrow occurs here
105 LL |     let c2 = || *x.f = 5;
106    |              ^^ ---- second borrow occurs due to use of `x` in closure
107    |              |
108    |              mutable borrow occurs here
109 LL |
110 LL |     drop(c1);
111    |          -- immutable borrow later used here
112
113 error: aborting due to 8 previous errors
114
115 Some errors have detailed explanations: E0502, E0506.
116 For more information about an error, try `rustc --explain E0502`.