fork/rust

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

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

master
2.3 KiB69 linesraw
1error[E0505]: cannot move out of `x` because it is borrowed
2  --> $DIR/borrow-tuple-fields.rs:12:13
3   |
4LL |     let x: (Box<_>, _) = (Box::new(1), 2);
5   |         - binding `x` declared here
6LL |     let r = &x.0;
7   |             ---- borrow of `x.0` occurs here
8LL |     let y = x;
9   |             ^ move out of `x` occurs here
10LL |
11LL |     r.use_ref();
12   |     - borrow later used here
13
14error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
15  --> $DIR/borrow-tuple-fields.rs:18:13
16   |
17LL |     let a = &x.0;
18   |             ---- immutable borrow occurs here
19LL |     let b = &mut x.0;
20   |             ^^^^^^^^ mutable borrow occurs here
21LL |     a.use_ref();
22   |     - immutable borrow later used here
23
24error[E0499]: cannot borrow `x.0` as mutable more than once at a time
25  --> $DIR/borrow-tuple-fields.rs:23:13
26   |
27LL |     let a = &mut x.0;
28   |             -------- first mutable borrow occurs here
29LL |     let b = &mut x.0;
30   |             ^^^^^^^^ second mutable borrow occurs here
31LL |     a.use_ref();
32   |     - first borrow later used here
33
34error[E0505]: cannot move out of `x` because it is borrowed
35  --> $DIR/borrow-tuple-fields.rs:28:13
36   |
37LL |     let x = Foo(Box::new(1), 2);
38   |         - binding `x` declared here
39LL |     let r = &x.0;
40   |             ---- borrow of `x.0` occurs here
41LL |     let y = x;
42   |             ^ move out of `x` occurs here
43LL |     r.use_ref();
44   |     - borrow later used here
45
46error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
47  --> $DIR/borrow-tuple-fields.rs:33:13
48   |
49LL |     let a = &x.0;
50   |             ---- immutable borrow occurs here
51LL |     let b = &mut x.0;
52   |             ^^^^^^^^ mutable borrow occurs here
53LL |     a.use_ref();
54   |     - immutable borrow later used here
55
56error[E0499]: cannot borrow `x.0` as mutable more than once at a time
57  --> $DIR/borrow-tuple-fields.rs:38:13
58   |
59LL |     let a = &mut x.0;
60   |             -------- first mutable borrow occurs here
61LL |     let b = &mut x.0;
62   |             ^^^^^^^^ second mutable borrow occurs here
63LL |     a.use_mut();
64   |     - first borrow later used here
65
66error: aborting due to 6 previous errors
67
68Some errors have detailed explanations: E0499, E0502, E0505.
69For more information about an error, try `rustc --explain E0499`.