Stream: t-compiler

Topic: canonical deref #53843


Ariel Ben-Yehuda (Sep 03 2018 at 19:11, on Zulip):

@nikomatsakis

you online?

Ariel Ben-Yehuda (Sep 03 2018 at 19:15, on Zulip):

I had some thoughts about #53843

The issue there is that autoderef does not resolve nested obligations while evaluating the chain.

The problem is that autoderef runs in a "probe" context from which the fulfillcx can't be accessed. I think the solution would be to move autoderef to be a canonical query, where autoderef(Γ ⊢ canonical--ty, n) is an (canonical-substs, ty, obligations) triple.

Ariel Ben-Yehuda (Sep 03 2018 at 19:19, on Zulip):

The current QueryResult struct does not support returning obligations, so I was wondering whether the best way of handling this would be by having a separate "probe" and "confirm" stages, where only the confirm returns obligations.

Vadim Petrochenkov (Sep 03 2018 at 22:33, on Zulip):

@nikomatsakis Could you look at https://github.com/rust-lang/rust/pull/53778 sooner?
It's a prerequisite for a number of other PRs that need to be done until beta (which is pretty soon).

nikomatsakis (Sep 04 2018 at 12:45, on Zulip):

@Ariel Ben-Yehuda hmm, the goal with queries is not to have to return obligations, but instead to "fully process" the obligations in situ, and just return the results. Does that not work in this case — perhaps because of ambiguity?

nikomatsakis (Sep 04 2018 at 12:45, on Zulip):

@Vadim Petrochenkov (sure)

Ariel Ben-Yehuda (Sep 04 2018 at 18:10, on Zulip):

@nikomatsakis

Sure. The intent of autoderef is that, say, when you want to deref Vec<$0>, you will get [$0] (the ref type is "implicit"). If that deref impl had obligations on $0 (I can't seem to find any), they would also need to be processed.

Ariel Ben-Yehuda (Sep 04 2018 at 18:14, on Zulip):

Or if you autoderef Pin<Option<$0>>, you get Option<$0> where $0: Unpin

Or in canonical language, that would be something like dest = Option<$α>, substs = [$0 <- $α], obligations = [$α: Unpin] where α is the "canonical output" type.

nikomatsakis (Sep 04 2018 at 18:35, on Zulip):

Hmm. Yes, of course. So we want to do some sort of "shallow" testing. Well, in any case, it should be possible to create a canonical query result that includes obligations without any great difficulty.

nikomatsakis (Sep 04 2018 at 18:36, on Zulip):

The current QueryResult struct does not support returning obligations, so I was wondering whether the best way of handling this would be by having a separate "probe" and "confirm" stages, where only the confirm returns obligations.

I'm re-reading this question of yours :)

nikomatsakis (Sep 04 2018 at 18:37, on Zulip):

I'm not sure if the probe/confirm is worth it, trying to think that over. It seems like you could just have a QueryResult<AutoDerefResult> where the AutoDerefResult includes the "deferred" obligations that we do not evaluate

nikomatsakis (Sep 04 2018 at 18:38, on Zulip):

this is going to be a fun thing to figure out in chalk :P

Last update: Nov 22 2019 at 04:30UTC