]> git.proxmox.com Git - rustc.git/blame - src/test/ui/run-pass/specialization/specialization-translate-projections.rs
New upstream version 1.30.0+dfsg1
[rustc.git] / src / test / ui / run-pass / specialization / specialization-translate-projections.rs
CommitLineData
54a0048b
SL
1// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
b7449926
XL
11// run-pass
12
54a0048b
SL
13// Ensure that provided items are inherited properly even when impls vary in
14// type parameters *and* rely on projections.
15
16#![feature(specialization)]
17
18use std::convert::Into;
19
20trait Trait {
21 fn to_u8(&self) -> u8;
22}
23trait WithAssoc {
24 type Item;
25 fn to_item(&self) -> Self::Item;
26}
27
28impl<T, U> Trait for T where T: WithAssoc<Item=U>, U: Into<u8> {
29 fn to_u8(&self) -> u8 {
30 self.to_item().into()
31 }
32}
33
34impl WithAssoc for u8 {
35 type Item = u8;
36 fn to_item(&self) -> u8 { *self }
37}
38
39impl Trait for u8 {}
40
41fn main() {
42 assert!(3u8.to_u8() == 3u8);
43}