Skip to content

Commit e4710fe

Browse files
committed
Add test for T: suggestions
1 parent de2edb2 commit e4710fe

3 files changed

+61
-1
lines changed

src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed

+14
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,18 @@ where
6969
(t, t) //~ use of moved value: `t`
7070
}
7171

72+
#[rustfmt::skip]
73+
fn existing_colon<T: Copy>(t: T) {
74+
//~^ HELP consider restricting type parameter `T`
75+
[t, t]; //~ use of moved value: `t`
76+
}
77+
78+
fn existing_colon_in_where<T>(t: T)
79+
where
80+
T: Copy,
81+
//~^ HELP consider further restricting this bound
82+
{
83+
[t, t]; //~ use of moved value: `t`
84+
}
85+
7286
fn main() {}

src/test/ui/moves/use_of_moved_value_copy_suggestions.rs

+14
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,18 @@ where
6969
(t, t) //~ use of moved value: `t`
7070
}
7171

72+
#[rustfmt::skip]
73+
fn existing_colon<T:>(t: T) {
74+
//~^ HELP consider restricting type parameter `T`
75+
[t, t]; //~ use of moved value: `t`
76+
}
77+
78+
fn existing_colon_in_where<T>(t: T)
79+
where
80+
T:,
81+
//~^ HELP consider further restricting this bound
82+
{
83+
[t, t]; //~ use of moved value: `t`
84+
}
85+
7286
fn main() {}

src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr

+33-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,38 @@ help: consider further restricting this bound
142142
LL | T: B + Trait + Copy,
143143
| ++++++++++++++
144144

145-
error: aborting due to 9 previous errors
145+
error[E0382]: use of moved value: `t`
146+
--> $DIR/use_of_moved_value_copy_suggestions.rs:83:9
147+
|
148+
LL | fn existing_colon_in_where<T>(t: T)
149+
| - move occurs because `t` has type `T`, which does not implement the `Copy` trait
150+
...
151+
LL | [t, t];
152+
| - ^ value used here after move
153+
| |
154+
| value moved here
155+
|
156+
help: consider further restricting this bound
157+
|
158+
LL | T: Copy,
159+
| ++++
160+
161+
error[E0382]: use of moved value: `t`
162+
--> $DIR/use_of_moved_value_copy_suggestions.rs:75:9
163+
|
164+
LL | fn existing_colon<T:>(t: T) {
165+
| - move occurs because `t` has type `T`, which does not implement the `Copy` trait
166+
LL |
167+
LL | [t, t];
168+
| - ^ value used here after move
169+
| |
170+
| value moved here
171+
|
172+
help: consider restricting type parameter `T`
173+
|
174+
LL | fn existing_colon<T: Copy>(t: T) {
175+
| ++++
176+
177+
error: aborting due to 11 previous errors
146178

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

0 commit comments

Comments
 (0)