]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.stderr
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / borrowck / borrowck-closures-mut-and-imm.ast.stderr
1 error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
2   --> $DIR/borrowck-closures-mut-and-imm.rs:21:14
3    |
4 LL |     let c1 = || x = 4;
5    |              -- - previous borrow occurs due to use of `x` in closure
6    |              |
7    |              mutable borrow occurs here
8 LL |     let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
9    |              ^^ - borrow occurs due to use of `x` in closure
10    |              |
11    |              immutable borrow occurs here
12 ...
13 LL | }
14    | - mutable borrow ends 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:29:14
18    |
19 LL |     let c1 = || set(&mut x);
20    |              --          - previous borrow occurs due to use of `x` in closure
21    |              |
22    |              mutable borrow occurs here
23 LL |     let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x`
24    |              ^^      - borrow occurs due to use of `x` in closure
25    |              |
26    |              immutable borrow occurs here
27 ...
28 LL | }
29    | - mutable borrow ends 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:37:14
33    |
34 LL |     let c1 = || set(&mut x);
35    |              --          - previous borrow occurs due to use of `x` in closure
36    |              |
37    |              mutable borrow occurs here
38 LL |     let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
39    |              ^^ - borrow occurs due to use of `x` in closure
40    |              |
41    |              immutable borrow occurs here
42 ...
43 LL | }
44    | - mutable borrow ends here
45
46 error[E0506]: cannot assign to `x` because it is borrowed
47   --> $DIR/borrowck-closures-mut-and-imm.rs:45:5
48    |
49 LL |     let c2 = || x * 5;
50    |              -- borrow of `x` occurs here
51 LL |     x = 5; //[ast]~ ERROR cannot assign
52    |     ^^^^^ assignment to borrowed `x` occurs here
53
54 error[E0506]: cannot assign to `x` because it is borrowed
55   --> $DIR/borrowck-closures-mut-and-imm.rs:53:5
56    |
57 LL |     let c1 = || get(&x);
58    |              -- borrow of `x` occurs here
59 LL |     x = 5; //[ast]~ ERROR cannot assign
60    |     ^^^^^ assignment to borrowed `x` occurs here
61
62 error[E0506]: cannot assign to `*x` because it is borrowed
63   --> $DIR/borrowck-closures-mut-and-imm.rs:61:5
64    |
65 LL |     let c1 = || get(&*x);
66    |              -- borrow of `*x` occurs here
67 LL |     *x = 5; //[ast]~ ERROR cannot assign to `*x`
68    |     ^^^^^^ assignment to borrowed `*x` occurs here
69
70 error[E0506]: cannot assign to `*x.f` because it is borrowed
71   --> $DIR/borrowck-closures-mut-and-imm.rs:73:5
72    |
73 LL |     let c1 = || get(&*x.f);
74    |              -- borrow of `*x.f` occurs here
75 LL |     *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f`
76    |     ^^^^^^^^ assignment to borrowed `*x.f` occurs here
77
78 error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
79   --> $DIR/borrowck-closures-mut-and-imm.rs:85:14
80    |
81 LL |     let c1 = || get(&*x.f);
82    |              --       - previous borrow occurs due to use of `x` in closure
83    |              |
84    |              immutable borrow occurs here
85 LL |     let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable
86    |              ^^  - borrow occurs due to use of `x` in closure
87    |              |
88    |              mutable borrow occurs here
89 ...
90 LL | }
91    | - immutable borrow ends here
92
93 error: aborting due to 8 previous errors
94
95 Some errors occurred: E0502, E0506.
96 For more information about an error, try `rustc --explain E0502`.