]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/defaults-in-other-trait-items-pass.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / associated-types / defaults-in-other-trait-items-pass.rs
1 // check-pass
2
3 #![feature(associated_type_defaults)]
4
5 trait Tr {
6     type Item = u8;
7     type Container = Vec<Self::Item>;
8 }
9
10 impl Tr for () {}
11
12 impl Tr for u16 {
13     type Item = u16;
14 }
15
16 impl Tr for String {
17     type Container = String;
18 }
19
20 impl Tr for usize {
21     type Item = u32;
22     type Container = Vec<()>;
23 }
24
25 fn main() {
26     let _container: <() as Tr>::Container = Vec::<u8>::new();
27     let _item: <() as Tr>::Item = 0u8;
28
29     let _container: <u16 as Tr>::Container = Vec::<u16>::new();
30     let _item: <u16 as Tr>::Item = 0u16;
31
32     let _container: <String as Tr>::Container = String::new();
33     let _item: <String as Tr>::Item = 0u8;
34
35     let _container: <usize as Tr>::Container = Vec::<()>::new();
36     let _item: <usize as Tr>::Item = 0u32;
37 }