Closed
Description
The following code fails to compile (playground):
#![feature(existential_type)]
trait Bar {
type A;
}
impl Bar for () {
type A = ();
}
trait Foo {
type A;
type B: Bar<A = Self::A>;
fn foo() -> Self::B;
}
impl Foo for () {
type A = ();
existential type B: Bar<A = Self::A>;
fn foo() -> Self::B {
()
}
}
with the following error
error[E0271]: type mismatch resolving `<() as Bar>::A == <() as Foo>::A`
--> src/lib.rs:20:5
|
20 | existential type B: Bar<A = Self::A>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found associated type
|
= note: expected type `()`
found type `<() as Foo>::A`
= note: the return type of a function must have a statically known size
If you make this modification, it compiles fine:
- existential type B: Bar<A = Self::A>;
+ existential type B: Bar<A = ()>;
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done