Description
EDIT: To anyone coming to this from the This Week in Rust CFP: This is currently an unsolved issue, so the first step to tackling this is to figure out where the bug is! That alone would be a huge help. If you want to implement a fix, that'd be great too :)
=====
The following program should compile on stable, but doesn't:
trait ConstDefault {
const Default: Self;
}
trait Foo: Sized {}
trait FooExt: Foo {
type T: ConstDefault;
}
trait Bar<F: FooExt> {
const T: F::T;
}
impl<F: FooExt> Bar<F> for () {
const T: F::T = <F::T as ConstDefault>::Default;
}
It fails to compile with the following error:
error[E0277]: the trait bound `F: FooExt` is not satisfied
--> src/lib.rs:16:5
|
16 | const T: F::T = <F::T as ConstDefault>::Default;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FooExt` is not implemented for `F`
|
= help: consider adding a `where F: FooExt` bound
Note that if we amend as either of the following, it works (credit to @ezrosent for figuring this out):
trait Bar<T: ConstDefault, F: FooExt<T=T>> {
const C: T;
}
impl<T: ConstDefault, F: FooExt<T=T>> Bar<T, F> for () {
const C: T = F::T::Default;
const C: T = T::Default;
}