]> git.lizzy.rs Git - rust.git/blob - tests/ui/generic-associated-types/type-param-defaults.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / generic-associated-types / type-param-defaults.rs
1 // Check that we disallow GAT param defaults, even with `invalid_type_param_default` allowed
2
3 #![allow(invalid_type_param_default)]
4
5 trait Trait {
6     type Assoc<T = u32>;
7     //~^ defaults for type parameters are only allowed
8 }
9
10 impl Trait for () {
11     type Assoc<T = u32> = u64;
12     //~^ defaults for type parameters are only allowed
13 }
14
15 impl Trait for u32 {
16     type Assoc<T = u32> = T;
17     //~^ defaults for type parameters are only allowed
18 }
19
20 trait Other {}
21 impl Other for u32 {}
22
23 fn foo<T>()
24 where
25     T: Trait<Assoc = u32>,
26     T::Assoc: Other {
27     }
28
29 fn main() {
30     // errors
31     foo::<()>();
32     // works
33     foo::<u32>();
34 }