]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-projection-to-unrelated-trait.rs
feat(rustdoc): open sidebar menu when links inside it are focused
[rust.git] / src / test / ui / associated-types / associated-types-projection-to-unrelated-trait.rs
1 // run-pass
2 // Check that we do not get an error when you use `<Self as Get>::Value` in
3 // the trait definition if there is no default method and for every impl,
4 // `Self` does implement `Get`.
5 //
6 // See also tests associated-types-no-suitable-supertrait
7 // and associated-types-no-suitable-supertrait-2, which show how small
8 // variants of the code below can fail.
9
10 trait Get {
11     type Value;
12 }
13
14 trait Other {
15     fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value)
16         where Self: Get;
17 }
18
19 impl Get for () {
20     type Value = f32;
21 }
22
23 impl Get for f64 {
24     type Value = u32;
25 }
26
27 impl Other for () {
28     fn okay<U:Get>(&self, _foo: U, _bar: <Self as Get>::Value) { }
29 }
30
31 impl Other for f64 {
32     fn okay<U:Get>(&self, _foo: U, _bar: <Self as Get>::Value) { }
33 }
34
35 fn main() { }