-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-type-systemArea: Type systemArea: Type systemF-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-type-systemArea: Type systemArea: Type systemF-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Type
Projects
Status
Done