1 #![feature(associated_type_defaults)]
3 // Associated type defaults may not be assumed inside the trait defining them.
4 // ie. they only resolve to `<Self as Tr>::A`, not the actual type `()`
6 type A = (); //~ NOTE associated type defaults can't be assumed inside the trait defining them
10 //~^ ERROR mismatched types
11 //~| NOTE expected associated type, found `()`
12 //~| NOTE expected associated type `<Self as Tr>::A`
13 //~| NOTE this expression has type `<Self as Tr>::A`
17 // An impl that doesn't override the type *can* assume the default.
33 type Ty = u8; //~ NOTE associated type defaults can't be assumed inside the trait defining them
35 // Assoc. consts also cannot assume that default types hold
36 const C: Self::Ty = 0u8;
37 //~^ ERROR mismatched types
38 //~| NOTE expected associated type, found `u8`
39 //~| NOTE expected associated type `<Self as AssocConst>::Ty`
42 // An impl can, however
43 impl AssocConst for () {
44 const C: Self::Ty = 0u8;