]> git.lizzy.rs Git - rust.git/blob - tests/ui/moves/move-fn-self-receiver.stderr
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
[rust.git] / tests / ui / moves / move-fn-self-receiver.stderr
1 error[E0382]: use of moved value: `val.0`
2   --> $DIR/move-fn-self-receiver.rs:30:5
3    |
4 LL |     val.0.into_iter().next();
5    |           ----------- `val.0` moved due to this method call
6 LL |     val.0;
7    |     ^^^^^ value used here after move
8    |
9 note: `into_iter` takes ownership of the receiver `self`, which moves `val.0`
10   --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
11    = note: move occurs because `val.0` has type `Vec<bool>`, which does not implement the `Copy` trait
12 help: you can `clone` the value and consume it, but this might not be your desired behavior
13    |
14 LL |     val.0.clone().into_iter().next();
15    |           ++++++++
16
17 error[E0382]: use of moved value: `foo`
18   --> $DIR/move-fn-self-receiver.rs:34:5
19    |
20 LL |     let foo = Foo;
21    |         --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
22 LL |     foo.use_self();
23    |         ---------- `foo` moved due to this method call
24 LL |     foo;
25    |     ^^^ value used here after move
26    |
27 note: `Foo::use_self` takes ownership of the receiver `self`, which moves `foo`
28   --> $DIR/move-fn-self-receiver.rs:13:17
29    |
30 LL |     fn use_self(self) {}
31    |                 ^^^^
32
33 error[E0382]: use of moved value: `second_foo`
34   --> $DIR/move-fn-self-receiver.rs:38:5
35    |
36 LL |     let second_foo = Foo;
37    |         ---------- move occurs because `second_foo` has type `Foo`, which does not implement the `Copy` trait
38 LL |     second_foo.use_self();
39    |                ---------- `second_foo` moved due to this method call
40 LL |     second_foo;
41    |     ^^^^^^^^^^ value used here after move
42
43 error[E0382]: use of moved value: `boxed_foo`
44   --> $DIR/move-fn-self-receiver.rs:42:5
45    |
46 LL |     let boxed_foo = Box::new(Foo);
47    |         --------- move occurs because `boxed_foo` has type `Box<Foo>`, which does not implement the `Copy` trait
48 LL |     boxed_foo.use_box_self();
49    |               -------------- `boxed_foo` moved due to this method call
50 LL |     boxed_foo;
51    |     ^^^^^^^^^ value used here after move
52    |
53 note: `Foo::use_box_self` takes ownership of the receiver `self`, which moves `boxed_foo`
54   --> $DIR/move-fn-self-receiver.rs:14:21
55    |
56 LL |     fn use_box_self(self: Box<Self>) {}
57    |                     ^^^^
58
59 error[E0382]: use of moved value: `pin_box_foo`
60   --> $DIR/move-fn-self-receiver.rs:46:5
61    |
62 LL |     let pin_box_foo = Box::pin(Foo);
63    |         ----------- move occurs because `pin_box_foo` has type `Pin<Box<Foo>>`, which does not implement the `Copy` trait
64 LL |     pin_box_foo.use_pin_box_self();
65    |                 ------------------ `pin_box_foo` moved due to this method call
66 LL |     pin_box_foo;
67    |     ^^^^^^^^^^^ value used here after move
68    |
69 note: `Foo::use_pin_box_self` takes ownership of the receiver `self`, which moves `pin_box_foo`
70   --> $DIR/move-fn-self-receiver.rs:15:25
71    |
72 LL |     fn use_pin_box_self(self: Pin<Box<Self>>) {}
73    |                         ^^^^
74
75 error[E0505]: cannot move out of `mut_foo` because it is borrowed
76   --> $DIR/move-fn-self-receiver.rs:50:5
77    |
78 LL |     let ret = mut_foo.use_mut_self();
79    |               ---------------------- borrow of `mut_foo` occurs here
80 LL |     mut_foo;
81    |     ^^^^^^^ move out of `mut_foo` occurs here
82 LL |     ret;
83    |     --- borrow later used here
84
85 error[E0382]: use of moved value: `rc_foo`
86   --> $DIR/move-fn-self-receiver.rs:55:5
87    |
88 LL |     let rc_foo = Rc::new(Foo);
89    |         ------ move occurs because `rc_foo` has type `Rc<Foo>`, which does not implement the `Copy` trait
90 LL |     rc_foo.use_rc_self();
91    |            ------------- `rc_foo` moved due to this method call
92 LL |     rc_foo;
93    |     ^^^^^^ value used here after move
94    |
95 note: `Foo::use_rc_self` takes ownership of the receiver `self`, which moves `rc_foo`
96   --> $DIR/move-fn-self-receiver.rs:16:20
97    |
98 LL |     fn use_rc_self(self: Rc<Self>) {}
99    |                    ^^^^
100 help: you can `clone` the value and consume it, but this might not be your desired behavior
101    |
102 LL |     rc_foo.clone().use_rc_self();
103    |            ++++++++
104
105 error[E0382]: use of moved value: `foo_add`
106   --> $DIR/move-fn-self-receiver.rs:59:5
107    |
108 LL |     let foo_add = Foo;
109    |         ------- move occurs because `foo_add` has type `Foo`, which does not implement the `Copy` trait
110 LL |     foo_add + Foo;
111    |     ------------- `foo_add` moved due to usage in operator
112 LL |     foo_add;
113    |     ^^^^^^^ value used here after move
114    |
115 note: calling this operator moves the left-hand side
116   --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
117
118 error[E0382]: use of moved value: `implicit_into_iter`
119   --> $DIR/move-fn-self-receiver.rs:63:5
120    |
121 LL |     let implicit_into_iter = vec![true];
122    |         ------------------ move occurs because `implicit_into_iter` has type `Vec<bool>`, which does not implement the `Copy` trait
123 LL |     for _val in implicit_into_iter {}
124    |                 ------------------ `implicit_into_iter` moved due to this implicit call to `.into_iter()`
125 LL |     implicit_into_iter;
126    |     ^^^^^^^^^^^^^^^^^^ value used here after move
127    |
128 help: consider iterating over a slice of the `Vec<bool>`'s content to avoid moving into the `for` loop
129    |
130 LL |     for _val in &implicit_into_iter {}
131    |                 +
132
133 error[E0382]: use of moved value: `explicit_into_iter`
134   --> $DIR/move-fn-self-receiver.rs:67:5
135    |
136 LL |     let explicit_into_iter = vec![true];
137    |         ------------------ move occurs because `explicit_into_iter` has type `Vec<bool>`, which does not implement the `Copy` trait
138 LL |     for _val in explicit_into_iter.into_iter() {}
139    |                                    ----------- `explicit_into_iter` moved due to this method call
140 LL |     explicit_into_iter;
141    |     ^^^^^^^^^^^^^^^^^^ value used here after move
142    |
143 help: you can `clone` the value and consume it, but this might not be your desired behavior
144    |
145 LL |     for _val in explicit_into_iter.clone().into_iter() {}
146    |                                    ++++++++
147
148 error[E0382]: use of moved value: `container`
149   --> $DIR/move-fn-self-receiver.rs:71:5
150    |
151 LL |     let container = Container(vec![]);
152    |         --------- move occurs because `container` has type `Container`, which does not implement the `Copy` trait
153 LL |     for _val in container.custom_into_iter() {}
154    |                           ------------------ `container` moved due to this method call
155 LL |     container;
156    |     ^^^^^^^^^ value used here after move
157    |
158 note: `Container::custom_into_iter` takes ownership of the receiver `self`, which moves `container`
159   --> $DIR/move-fn-self-receiver.rs:23:25
160    |
161 LL |     fn custom_into_iter(self) -> impl Iterator<Item = bool> {
162    |                         ^^^^
163
164 error[E0382]: use of moved value: `foo2`
165   --> $DIR/move-fn-self-receiver.rs:75:9
166    |
167 LL |     let foo2 = Foo;
168    |         ---- move occurs because `foo2` has type `Foo`, which does not implement the `Copy` trait
169 LL |     loop {
170    |     ---- inside of this loop
171 LL |         foo2.use_self();
172    |         ^^^^ ---------- `foo2` moved due to this method call, in previous iteration of loop
173
174 error: aborting due to 12 previous errors
175
176 Some errors have detailed explanations: E0382, E0505.
177 For more information about an error, try `rustc --explain E0382`.