]> git.proxmox.com Git - rustc.git/blame - src/test/ui/coherence/coherence-rfc447-constrained.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / coherence / coherence-rfc447-constrained.rs
CommitLineData
b7449926 1// run-pass
92a42be0
SL
2// check that trait matching can handle impls whose types are only
3// constrained by a projection.
4
5trait IsU32 {}
6impl IsU32 for u32 {}
7
8trait Mirror { type Image: ?Sized; }
9impl<T: ?Sized> Mirror for T { type Image = T; }
10
11trait Bar {}
12impl<U: Mirror, V: Mirror<Image=L>, L: Mirror<Image=U>> Bar for V
13 where U::Image: IsU32 {}
14
15trait Foo { fn name() -> &'static str; }
16impl Foo for u64 { fn name() -> &'static str { "u64" } }
17impl<T: Bar> Foo for T { fn name() -> &'static str { "Bar" }}
18
19fn main() {
20 assert_eq!(<u64 as Foo>::name(), "u64");
21 assert_eq!(<u32 as Foo>::name(), "Bar");
22}