Description
I tried this code:
trait Super<T> {}
trait Foo: Super<<Self as Foo>::Bar> { type Bar; }
type BoxFoo = Box<Foo<Bar = u8>>;
The code should compile since Self::Bar
is the type parameter, not Self
.
Instead, it will fail with the following message:
the trait Foo cannot be made into an object
the trait cannot use Self as a type parameter in the supertrait listing
FYI the discussion that sparked this issue:
So this has to do with object safety -- any trait that references Self is not object safe because the true Self type is erased. However, the error doesn't seem appropriate in this case. I think this warrants a bug report at least to fix the error message, if not to relax the object safety check (because there could be something I don't see preventing it still... can't say I fully understand object safety).
Meta
rustc --version --verbose
: rustc 1.17.0-nightly (b1e31766d
2017-03-03)