]> git.lizzy.rs Git - rust.git/blob - src/test/ui/specialization/specialization-translate-projections-with-params.rs
bdc6501df44b84e99a82bd4f875dfc481f6a3240
[rust.git] / src / test / ui / specialization / specialization-translate-projections-with-params.rs
1 // run-pass
2
3 // Ensure that provided items are inherited properly even when impls vary in
4 // type parameters *and* rely on projections, and the type parameters are input
5 // types on the trait.
6
7 #![feature(specialization)]
8
9 trait Trait<T> {
10     fn convert(&self) -> T;
11 }
12 trait WithAssoc {
13     type Item;
14     fn as_item(&self) -> &Self::Item;
15 }
16
17 impl<T, U> Trait<U> for T where T: WithAssoc<Item=U>, U: Clone {
18     fn convert(&self) -> U {
19         self.as_item().clone()
20     }
21 }
22
23 impl WithAssoc for u8 {
24     type Item = u8;
25     fn as_item(&self) -> &u8 { self }
26 }
27
28 impl Trait<u8> for u8 {}
29
30 fn main() {
31     assert!(3u8.convert() == 3u8);
32 }