about summary refs log tree commit diff
path: root/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr
blob: 057960ec0142c3abe7826fe21a02e84a31840911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
error[E0505]: cannot move out of `value` because it is borrowed
  --> $DIR/if-let-guards-errors.rs:16:13
   |
LL |     let f = |x: &E| {
   |             ------- borrow of `value` occurs here
LL |         match &x {
LL |             E::Number(_) if let E::Number(ref mut n) = *value => { }
   |                                                        ------ borrow occurs due to use in closure
...
LL |     let x = value;
   |             ^^^^^ move out of `value` occurs here
LL |
LL |     drop(f);
   |          - borrow later used here

error[E0382]: use of moved value: `value`
  --> $DIR/if-let-guards-errors.rs:28:13
   |
LL | fn if_let_move(value: Box<E>) {
   |                ----- move occurs because `value` has type `Box<E>`, which does not implement the `Copy` trait
LL |     let f = |x: &E| {
   |             ------- value moved into closure here
LL |         match &x {
LL |             E::Number(_) if let E::String(s) = *value => { }
   |                                                ------ variable moved due to use in closure
...
LL |     let x = value;
   |             ^^^^^ value used here after move
   |
note: if `E` implemented `Clone`, you could clone the value
  --> $DIR/if-let-guards-errors.rs:32:1
   |
LL |             E::Number(_) if let E::String(s) = *value => { }
   |                                                ------ you could clone this value
...
LL | enum E {
   | ^^^^^^ consider implementing `Clone` for this type

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0382, E0505.
For more information about an error, try `rustc --explain E0382`.