Stream: wg-async-foundations

Topic: generators and data across yields

nikomatsakis (Feb 26 2019 at 22:44, on Zulip):

So @Taylor Cramer we did some more digging after you left. I didn't ever get to the bottom of the #53548 but we did dig into #57017 and find the code responsible.

nikomatsakis (Feb 26 2019 at 22:44, on Zulip):

The basic summary is what I said -- there is an "approximate" check that computes the "generator witness", which is a superset of the data that is really needed.

nikomatsakis (Feb 26 2019 at 22:46, on Zulip):

I'll maybe leave some comments on #57017, the relevant code is in, and particularly this part of it. It's presently pretty conservative -- it assumes that the result of each intermediate expression may be stored as long as the enclosing temporary scope.

nikomatsakis (Feb 26 2019 at 22:47, on Zulip):

I think we could probably make that more precise by modified the expr-use-visitor and using that to be smarter. This would certainly fix the example in question, though there'd probably still be a measure of imprecision involved. I didn't quite get to seeing clearly the change, have to think on it a bit.

Zoxc (Feb 26 2019 at 23:02, on Zulip):

I want to compute the generator interior on MIR, which should help with those cases

nikomatsakis (Feb 27 2019 at 13:50, on Zulip):

@Zoxc I don't think you can necessarily do that -- in particular, we need to know this information during the typeck phase, in order to compute (e.g.) whether something is Send.

nikomatsakis (Feb 27 2019 at 13:51, on Zulip):

Further, right now, type checking of the generator is intermingled with type-checking of the surrounding function (this is generally true for closures), so we can't be sure to be able to construct the MIR for the generator until type-checking of the overall fn is complete, and it seems to me that this could depend on whether the generator is Send etc

nikomatsakis (Feb 27 2019 at 13:52, on Zulip):

(We could potentially do some sort of best effort thing, and error around cycles, but I'm not sure how I feel about that, I'd like to at least explore if we can compute a better approximation of live data first)

Zoxc (Feb 27 2019 at 13:56, on Zulip):

We currently generate an error if we try to infer the generator interior of a generator, but don't know all the types inside. That should leave us room to construct MIR just for the generator in the future

nikomatsakis (Feb 27 2019 at 16:20, on Zulip):

Which error are you referring to?

Zoxc (Feb 27 2019 at 16:27, on Zulip):

Taylor Cramer (Mar 05 2019 at 18:56, on Zulip):

@nikomatsakis ^this convo seems relevant to the other ongoing thread

Taylor Cramer (Mar 05 2019 at 18:56, on Zulip):

cc @Giles Cope

nikomatsakis (Mar 05 2019 at 19:08, on Zulip):

@Taylor Cramer yes I was going to say that :)

nikomatsakis (Mar 05 2019 at 19:08, on Zulip):

when I mentioned "I have a hunch what the problem is", I was thinking of this...

Last update: Aug 13 2020 at 09:15UTC