-
Notifications
You must be signed in to change notification settings - Fork 182
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
add basic support for dyn Trait
and impl Trait
#218
Comments
Mentoring instructions for extending chalk-parserWe want to extend the grammar and AST to have Lines 81 to 86 in 6fd1808
|
Mentoring instructions for extending chalk-irExtending chalk-ir should be relatively straightforward, though there are some interesting raised by it. I think we want to extend the Line 217 in 6fd1808
to include two new variants, enum Ty {
...
Dyn(Vec<QuantifiedWhereClause>), // dyn Trait
Opaque(Vec<QuantifiedWhereClause>), // impl Trait
} These are the counterpart to the existing Line 244 in 6fd1808
we then have to adjust the lowering code to lower the AST to them, which would be done "sort of vaguely" like the existing code for Note that these types introduce a level of binder -- this is so that you can represent the (unknown)
where |
(Also, the mentoring instructions here are fairly sketchy, consider it as future work) |
Has anyone started working on this? If not, I'd like to try and take a stab at this. |
I've opened #226 to further discuss the issues regarding the implementation on the chalk solver. |
OK, @KiChjang, so what's missing from your PR is that we need to extend the "clause" lowering code. The basic rule that we want to create is that whenever the "self-type" is This would be done in the "clauses" code -- which is the code that takes a goal we are trying to prove and produces the "program clauses" that could be used to do so. Most of this work is done in this function right now: chalk/chalk-solve/src/clauses.rs Lines 131 to 140 in df09cc6
and in particular I think the first thing we want to do is to extend this case, where we are trying to prove case like chalk/chalk-solve/src/clauses.rs Line 142 in df09cc6
What I think we want to do is to add a new case, right around this "FIXME" line at the end. In particular, we want to look at the self type and check whether it is a "dyn" or "impl" trait type. If you rebase this PR on master, you'll find a convenient helper on the These This isn't as targeted as it could be. For example, if we're being asked for program clauses to solve |
The next step here is #275 |
So I think this is basically done. There are some caveats worth keeping in mind. For example, chalk assumes presently that the binders in a dyn/impl Trait are sorted into a canonical ordering. In any case, I'm going to close this, thanks @KiChjang ❤️ |
Status: @KiChjang is working on the first steps.
The goal here is to extend chalk with basic support for
dyn Trait
and (opaque)impl Trait
types. This involves a few steps:dyn
andimpl
syntax, along with the astchalk-ir
to be able to represent such typeschalk-solve
so that when we have to prove something likedyn Foo: Foo
, we judge that to be true (similarlyimpl Foo: Foo
) -- blocked on Port DomainGoal matching from rustc #216dyn Foo
with a struct type (error)impl Foo
with a struct type (error)dyn Foo: Foo
(without any impl)dyn Foo: Bar
does not holdimpl Foo: Foo
(without any impl)impl Foo: Bar
does not holdThis is judged to be a "medium" complex project, suitable for a dedicated beginner. After this work is done, the next step is #203.
The text was updated successfully, but these errors were encountered: