about summary refs log tree commit diff
path: root/tests/ui/suggestions/option-content-move3.stderr
blob: f78d3cf6786297ff61ea8eaf57f477a217e6d2f4 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
  --> $DIR/option-content-move3.rs:13:21
   |
LL |     let var = NotCopyable;
   |         --- captured outer variable
...
LL |         move || {
   |         ------- captured by this `FnMut` closure
LL |             let x = var;
   |                     ^^^ move occurs because `var` has type `NotCopyable`, which does not implement the `Copy` trait
   |
   = help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once
note: if `NotCopyable` implemented `Clone`, you could clone the value
  --> $DIR/option-content-move3.rs:2:1
   |
LL | struct NotCopyable;
   | ^^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |             let x = var;
   |                     --- you could clone this value
help: consider borrowing here
   |
LL |             let x = &var;
   |                     +

error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
  --> $DIR/option-content-move3.rs:12:9
   |
LL |     let var = NotCopyable;
   |         ---   ----------- move occurs because `var` has type `NotCopyable`, which does not implement the `Copy` trait
   |         |
   |         captured outer variable
LL |     func(|| {
   |          -- captured by this `FnMut` closure
LL |         // Shouldn't suggest `move ||.as_ref()` here
LL |         move || {
   |         ^^^^^^^ `var` is moved here
LL |             let x = var;
   |                     --- variable moved due to use in closure
   |
help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once
  --> $DIR/option-content-move3.rs:6:12
   |
LL | fn func<F: FnMut() -> H, H: FnMut()>(_: F) {}
   |            ^^^^^^^^^^^^
note: if `NotCopyable` implemented `Clone`, you could clone the value
  --> $DIR/option-content-move3.rs:2:1
   |
LL | struct NotCopyable;
   | ^^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |             let x = var;
   |                     --- you could clone this value

error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
  --> $DIR/option-content-move3.rs:24:21
   |
LL |     let var = NotCopyableButCloneable;
   |         --- captured outer variable
...
LL |         move || {
   |         ------- captured by this `FnMut` closure
LL |             let x = var;
   |                     ^^^ move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait
   |
   = help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once
help: consider borrowing here
   |
LL |             let x = &var;
   |                     +

error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
  --> $DIR/option-content-move3.rs:23:9
   |
LL |     let var = NotCopyableButCloneable;
   |         ---   ----------------------- move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait
   |         |
   |         captured outer variable
LL |     func(|| {
   |          -- captured by this `FnMut` closure
LL |         // Shouldn't suggest `move ||.as_ref()` here
LL |         move || {
   |         ^^^^^^^ `var` is moved here
LL |             let x = var;
   |                     --- variable moved due to use in closure
   |
help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once
  --> $DIR/option-content-move3.rs:6:12
   |
LL | fn func<F: FnMut() -> H, H: FnMut()>(_: F) {}
   |            ^^^^^^^^^^^^
help: consider cloning the value before moving it into the closure
   |
LL ~         {
LL +         let value = var.clone();
LL ~         move || {
LL ~             let x = value;
LL |             println!("{x:?}");
LL ~         }
LL +         }
   |

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0507`.