]> git.lizzy.rs Git - rust.git/blob - tests/ui/where-clauses/where-clauses-method-unsatisfied.rs
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / ui / where-clauses / where-clauses-method-unsatisfied.rs
1 // Test that a where clause attached to a method allows us to add
2 // additional constraints to a parameter out of scope.
3
4 struct Foo<T> {
5     value: T
6 }
7
8 struct Bar; // does not implement Eq
9
10 impl<T> Foo<T> {
11     fn equals(&self, u: &Foo<T>) -> bool where T : Eq {
12         self.value == u.value
13     }
14 }
15
16 fn main() {
17     let x = Foo { value: Bar };
18     x.equals(&x);
19     //~^ ERROR `Bar: Eq` is not satisfied
20 }