1 #![feature(associated_type_defaults)]
2 
3 // Tests that a trait with one defaulted and one non-defaulted assoc. type behaves properly.
4 
5 trait Trait {
6     type Foo = u8;
7     type Bar;
8 }
9 
10 // `Bar` must be specified
11 impl Trait for () {}
12 //~^ error: not all trait items implemented, missing: `Bar`
13 
14 impl Trait for bool {
15 //~^ error: not all trait items implemented, missing: `Bar`
16     type Foo = ();
17 }
18 
19 impl Trait for u8 {
20     type Bar = ();
21 }
22 
23 impl Trait for u16 {
24     type Foo = String;
25     type Bar = bool;
26 }
27 
main()28 fn main() {
29     let _: <u8 as Trait>::Foo = 0u8;
30     let _: <u8 as Trait>::Bar = ();
31 
32     let _: <u16 as Trait>::Foo = String::new();
33     let _: <u16 as Trait>::Bar = true;
34 }
35