You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With BAssoc = () the code fails to compile with the following error:
error[E0277]: the trait bound `(): From<<T as A>::AAssoc>` is not satisfied
--> src/lib.rs:13:5
|
5 | pub trait B
| - required by a bound in this
6 | where
7 | Self: Into<<Self as B>::BAssoc>
| ------------------------- required by this bound in `B`
...
13 | x.into()
| ^^^^^^^^ the trait `From<<T as A>::AAssoc>` is not implemented for `()`
|
= note: required because of the requirements on the impl of `Into<()>` for `<T as A>::AAssoc`
error[E0308]: mismatched types
--> src/lib.rs:13:5
|
12 | fn test<T: A>(x: T::AAssoc) -> <T::AAssoc as B>::BAssoc {
| ------------------------ expected `()` because of return type
13 | x.into()
| ^^^^^^^^- help: try adding a semicolon: `;`
| |
| expected `()`, found associated type
|
= note: expected unit type `()`
found associated type `<<T as A>::AAssoc as B>::BAssoc`
= help: consider constraining the associated type `<<T as A>::AAssoc as B>::BAssoc` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
That seems really weird - how making type less generic makes code that should work for any type fail?
Meta
Tested on stable 1.46.0 and 1.48.0-nightly (2020-09-20 1fd5b9d)
The text was updated successfully, but these errors were encountered:
This code compiles fine until you'll uncomment
BAssoc = ()
.With
BAssoc = ()
the code fails to compile with the following error:That seems really weird - how making type less generic makes code that should work for any type fail?
Meta
Tested on stable
1.46.0
and1.48.0
-nightly (2020-09-20 1fd5b9d)The text was updated successfully, but these errors were encountered: