]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
92a42be0 SL |
2 | // check that trait matching can handle impls whose types are only |
3 | // constrained by a projection. | |
4 | ||
5 | trait IsU32 {} | |
6 | impl IsU32 for u32 {} | |
7 | ||
8 | trait Mirror { type Image: ?Sized; } | |
9 | impl<T: ?Sized> Mirror for T { type Image = T; } | |
10 | ||
11 | trait Bar {} | |
12 | impl<U: Mirror, V: Mirror<Image=L>, L: Mirror<Image=U>> Bar for V | |
13 | where U::Image: IsU32 {} | |
14 | ||
15 | trait Foo { fn name() -> &'static str; } | |
16 | impl Foo for u64 { fn name() -> &'static str { "u64" } } | |
17 | impl<T: Bar> Foo for T { fn name() -> &'static str { "Bar" }} | |
18 | ||
19 | fn main() { | |
20 | assert_eq!(<u64 as Foo>::name(), "u64"); | |
21 | assert_eq!(<u32 as Foo>::name(), "Bar"); | |
22 | } |