]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-no-suitable-supertrait.rs
feat(rustdoc): open sidebar menu when links inside it are focused
[rust.git] / src / test / ui / associated-types / associated-types-no-suitable-supertrait.rs
1 // Check that we get an error when you use `<Self as Get>::Value` in
2 // the trait definition but `Self` does not, in fact, implement `Get`.
3 //
4 // See also associated-types-no-suitable-supertrait-2.rs, which checks
5 // that we see the same error if we get around to checking the default
6 // method body.
7 //
8 // See also run-pass/associated-types-projection-to-unrelated-trait.rs,
9 // which checks that the trait interface itself is not considered an
10 // error as long as all impls satisfy the constraint.
11
12 trait Get {
13     type Value;
14 }
15
16 trait Other {
17     fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
18     //~^ ERROR the trait bound `Self: Get` is not satisfied
19 }
20
21 impl<T:Get> Other for T {
22     fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
23     //~^ ERROR the trait bound `(T, U): Get` is not satisfied
24 }
25
26 fn main() { }