Closed
Description
This example causes an ICE:
#![feature(default_type_params)]
trait Foo<T=Self> {
fn method(&self);
}
fn foo(x: &Foo) { }
fn main() { }
yields
<anon>:7:12: 7:15 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Self) substs=Substs[types=[[];[];[];[]], regions=[[];[];[];[]]]
This is because, in an object type, the self parameter slot is empty, so the substitution of the default fails. I'm not 100% sure what's the best way to fix this. We could make the substitution report a proper error rather than ICE; perhaps that's best.
It is debatable whether such a trait ought to be object safe, but it seems harmless, if pointless, since the Self
type winds up being revealed.