Given the following code: (play)
fn f<T>(_: impl A<X = T>) {}
trait A: C<Z = <<Self as A>::X as B>::Y> {
type X: B;
}
trait B {
type Y;
}
trait C {
type Z;
}
The current output is:
error[E0277]: the trait bound `T: B` is not satisfied
--> src/lib.rs:1:1
|
1 | fn f<T>(_: impl A<X = T>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `B` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
1 | fn f<T: B>(_: impl A<X = T>) {}
| +++
error[E0277]: the trait bound `T: B` is not satisfied
--> src/lib.rs:1:17
|
1 | fn f<T>(_: impl A<X = T>) {}
| ^^^^^^^^ the trait `B` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
1 | fn f<T: B>(_: impl A<X = T>) {}
| +++
This is confusing because it seems like this error is caused by type X: B in the trait, but actually it's caused by X as B in the supertraits, if your remove X as B the code compiles (as it should in any case, IMO!).
Ideally the code would compile or at least the output should look like:
error[E0277]: the trait bound `T: B` is not satisfied
--> src/lib.rs:1:1
|
1 | fn f<T>(_: impl A<X = T>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `B` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
1 | fn f<T: B>(_: impl A<X = T>) {}
| +++
note: required because of this
|
3 | trait A: C<Z = <<Self as A>::X as B>::Y> {
| ^^^^^^^^^^^^^^^^^^
@rustbot label +D-confusing
Given the following code: (play)
The current output is:
This is confusing because it seems like this error is caused by
type X: Bin the trait, but actually it's caused byX as Bin the supertraits, if your removeX as Bthe code compiles (as it should in any case, IMO!).Ideally the code would compile or at least the output should look like:
@rustbot label +D-confusing