Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler fails to unify existential associated type #57807

Closed
jonhoo opened this issue Jan 21, 2019 · 2 comments
Closed

Compiler fails to unify existential associated type #57807

jonhoo opened this issue Jan 21, 2019 · 2 comments

Comments

@jonhoo
Copy link
Contributor

@jonhoo jonhoo commented Jan 21, 2019

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 = ()>;
@jonhoo
Copy link
Contributor Author

@jonhoo jonhoo commented Jan 21, 2019

I think maybe cc @petrochenkov or @nikomatsakis ?

@jonhoo jonhoo changed the title Compiler fais to unify existential associated type Compiler fails to unify existential associated type Jan 21, 2019
@jonhoo
Copy link
Contributor Author

@jonhoo jonhoo commented Jan 21, 2019

I wonder whether this is a dupe of #53984 ?

Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jan 23, 2020
Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jan 24, 2020
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jan 25, 2020
…Centril

Add some type-alias-impl-trait regression tests

Fixes rust-lang#57611
Fixes rust-lang#57807
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jan 25, 2020
…Centril

Add some type-alias-impl-trait regression tests

Fixes rust-lang#57611
Fixes rust-lang#57807
@bors bors closed this in 1605276 Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants