blob: 25c46330e4d95a11bc31d6fe450c1b4d24ed47ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
fn require_copy<T: Copy>(x: T) {}
struct Bar<T> { x: T }
trait Foo<T> {
fn needs_copy(self) where T: Copy;
fn fails_copy(self);
}
// Ensure constraints are only attached to methods locally
impl<T> Foo<T> for Bar<T> {
fn needs_copy(self) where T: Copy {
require_copy(self.x);
}
fn fails_copy(self) {
require_copy(self.x);
//~^ ERROR the trait bound `T: Copy` is not satisfied
}
}
fn main() {}
|