Closed
Description
I tried this code:
#![feature(associated_type_defaults)]
use std::io::Read;
trait View {
type Deserializers: Deserializer<Item = Self::RequestParams>;
type RequestParams = DefaultRequestParams;
}
struct DefaultRequestParams;
trait Deserializer {
type Item;
fn deserialize(r: impl Read) -> Self::Item;
}
I expected to see this happen: View::Deserializers
has the as of yet unspecified type Deserializer<Item=Self::RequestParams>
.
Instead, this happened:
error[E0271]: type mismatch resolving `<<Self as View>::Deserializers as Deserializer>::Item == DefaultRequestParams`
--> src\lib.rs:17:38
|
14 | trait View {
| -------------- required by `View`
...
17 | type Deserializers: Deserializer<Item = Self::RequestParams>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `DefaultRequestParams`, found associated type
|
= note: expected struct `DefaultRequestParams`
found associated type `<Self as View>::RequestParams`
= help: consider constraining the associated type `<Self as View>::RequestParams` to `DefaultRequestParams`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
This error does not occur when the default is removed.
Meta
rustc --version --verbose
:
rustc 1.47.0-nightly (f44c6e4e2 2020-08-24)
See also: My initial question on the internals forum