Skip to content

preliminary model for "opaque types" where hidden types are known #335

@nikomatsakis

Description

@nikomatsakis

The goal here is to model Rust's impl Trait. For now the starting plan is to have a version where chalk is given both the opaque type declaration and the hidden type:

opaque type T<..>: Bounds = HiddenTy;

Note that opaque types can be generic.

We will model opaque types as an special kind of alias. Like associated types aliases, when an opaque type alias T is equated with some other type U, we will generate an AliasEq(T = U) goal.

The difference is that the two clauses for AliasEq goals work a bit differently. In particular, the "normalization" rule requires a special goal, Reveal, to be in the environment:

AliasEq(T = HiddenTy) :- Reveal.

AliasEq(T = !T).

There are also special rules for the !T placeholder:

Implemented(!T: Bounds). // from the declaration

// for auto traits:
Implemented(!T: AutoTrait) :- Implemented(HiddenTy: AutoTrait).

Metadata

Metadata

Assignees

Labels

C-chalk-solveIssues related to the chalk-solve cratecurrent-sprintBeing worked on in the current sprint

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions