]> git.lizzy.rs Git - rust.git/blob - tests/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / where-clauses / where-clause-constraints-are-local-for-trait-impl.rs
1 fn require_copy<T: Copy>(x: T) {}
2
3 struct Bar<T> { x: T }
4
5 trait Foo<T> {
6     fn needs_copy(self) where T: Copy;
7     fn fails_copy(self);
8 }
9
10 // Ensure constraints are only attached to methods locally
11 impl<T> Foo<T> for Bar<T> {
12     fn needs_copy(self) where T: Copy {
13         require_copy(self.x);
14
15     }
16
17     fn fails_copy(self) {
18         require_copy(self.x);
19         //~^ ERROR the trait bound `T: Copy` is not satisfied
20     }
21 }
22
23 fn main() {}