]> git.lizzy.rs Git - rust.git/commit
Fix cycle error with existential types
authorAaron Hill <aa1ronham@gmail.com>
Fri, 5 Jul 2019 20:24:58 +0000 (16:24 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sun, 7 Jul 2019 21:22:06 +0000 (17:22 -0400)
commit8ba9b1019c6e6c514826c5466e84d93f665f975f
treef336346fc600e789a45be997a771e1b1cc81dea1
parentdd2e8040a35883574ae0c4cc7a4e887ecb66469c
Fix cycle error with existential types

Fixes #61863

We now allow uses of 'existential type's that aren't defining uses -
that is, uses which don't constrain the underlying concrete type.

To make this work correctly, we also modify eq_opaque_type_and_type to
not try to apply additional constraints to an opaque type. If we have
code like this:

```
existential type Foo;
fn foo1() -> Foo { ... }
fn foo2() -> Foo { foo1() }
```

then 'foo2' doesn't end up constraining 'Foo', which means that
'foo2' will end up using the type 'Foo' internally - that is, an actual
'TyKind::Opaque'. We don't want to equate this to the underlying
concrete type - we just need to enforce the basic equality constraint
between the two types (here, the return type of 'foo1' and the return
type of 'foo2')
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_typeck/check/writeback.rs
src/test/run-pass/existential_type_const.rs [new file with mode: 0644]
src/test/run-pass/existential_type_const.stderr [new file with mode: 0644]
src/test/run-pass/existential_type_fns.rs [new file with mode: 0644]
src/test/ui/existential_types/existential-types-with-cycle-error.rs
src/test/ui/existential_types/existential-types-with-cycle-error.stderr
src/test/ui/existential_types/existential-types-with-cycle-error2.rs
src/test/ui/existential_types/existential-types-with-cycle-error2.stderr
src/test/ui/existential_types/no_inferrable_concrete_type.rs
src/test/ui/existential_types/no_inferrable_concrete_type.stderr