]> git.lizzy.rs Git - rust.git/blob - src/test/ui/coherence/coherence-rfc447-constrained.rs
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync
[rust.git] / src / test / ui / coherence / coherence-rfc447-constrained.rs
1 // run-pass
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 }