summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-types/defaults-in-other-trait-items-pass.rs
blob: a3bfcd8efe29acbdf5b1e50ce91b3407c6e55053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// check-pass

#![feature(associated_type_defaults)]

trait Tr {
    type Item = u8;
    type Container = Vec<Self::Item>;
}

impl Tr for () {}

impl Tr for u16 {
    type Item = u16;
}

impl Tr for String {
    type Container = String;
}

impl Tr for usize {
    type Item = u32;
    type Container = Vec<()>;
}

fn main() {
    let _container: <() as Tr>::Container = Vec::<u8>::new();
    let _item: <() as Tr>::Item = 0u8;

    let _container: <u16 as Tr>::Container = Vec::<u16>::new();
    let _item: <u16 as Tr>::Item = 0u16;

    let _container: <String as Tr>::Container = String::new();
    let _item: <String as Tr>::Item = 0u8;

    let _container: <usize as Tr>::Container = Vec::<()>::new();
    let _item: <usize as Tr>::Item = 0u32;
}