fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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