Closed
Description
I tried this code: playground
#![feature(generic_associated_types)]
#![allow(invalid_type_param_default)]
trait Trait {
type Assoc<T = u32>;
}
impl Trait for () {
type Assoc<T = u32> = u64;
}
impl Trait for u32 {
type Assoc<T = u32> = T;
}
trait Other {}
impl Other for u32 {}
fn foo<T>()
where
T: Trait<Assoc = u32>,
T::Assoc: Other {
}
fn main() {
// errors
foo::<()>();
// works
foo::<u32>();
}
I expected to see this happen: It not work correctly as if you remove #![allow(invalid_type_param_default)]
it shouts at you saying its unsupported and will be a hard error one day.
Instead, this happened: defaults on GATs seem to function perfectly fine
Meta
version from playground:
1.64.0-nightly
(2022-07-12 1c7b36d4db582cb47513)
cc @jackh726 this is probably should either be allowed or a hard error before stabilisation?