Stream: t-compiler

Topic: not Send due to await retainment #67611


pnkfelix (Jan 06 2020 at 20:44, on Zulip):

hey @Matthew Jasper are you around? I wanted to get your opinion on what steps we should take here

Matthew Jasper (Jan 06 2020 at 20:46, on Zulip):

I am. I wondered if there was any code that would hit this...

pnkfelix (Jan 06 2020 at 20:48, on Zulip):

I'm pretty sure this should not be considered a compiler bug. The following patch fixes the crate: https://gist.github.com/pnkfelix/4bdef50d0538fee8f6e0cbc4379f6074

pnkfelix (Jan 06 2020 at 20:48, on Zulip):

I was a little surprised that my first attempt of using unsafe { &PROXY[..] } (i.e. just adding [..]) did not work. I had to actually call .as_slice().

pnkfelix (Jan 06 2020 at 20:50, on Zulip):

is there anything analogous to move ||. but for generators? I.e. something that forces the generator to take a moved value rather than capturing a reference?

pnkfelix (Jan 06 2020 at 20:50, on Zulip):

(and my other question is whether we should consider trying to improve the diagnostics here or not)

Matthew Jasper (Jan 06 2020 at 20:53, on Zulip):

Hmm. So I think that there are some possible fixes for this issue by make how we determine what a generator is holding across a yield a bit smarter, or by adjusting MIR lowering so that we don't ever hold on to the temporary pointer across a yield.

Matthew Jasper (Jan 06 2020 at 20:53, on Zulip):

async move should work

pnkfelix (Jan 06 2020 at 20:55, on Zulip):

so you can do async move fn foo(..) { ... } ?

Matthew Jasper (Jan 06 2020 at 20:55, on Zulip):

No, but the function's parameters are always captured by move.

pnkfelix (Jan 06 2020 at 20:56, on Zulip):

But the statics aren't...

pnkfelix (Jan 06 2020 at 20:56, on Zulip):

(that was the case I was thinking of)

Matthew Jasper (Jan 06 2020 at 20:57, on Zulip):

statics aren't captured

pnkfelix (Jan 06 2020 at 20:58, on Zulip):

maybe I'm not using the right terminology

pnkfelix (Jan 06 2020 at 20:59, on Zulip):

statics are handled by making unsafe references to them, right?

pnkfelix (Jan 06 2020 at 20:59, on Zulip):

that is at least how I interpreted what is happening here.

Matthew Jasper (Jan 06 2020 at 20:59, on Zulip):

Yes

pnkfelix (Jan 06 2020 at 21:01, on Zulip):

lets go back to the ideas you had for solutions.

Matthew Jasper (Jan 06 2020 at 21:01, on Zulip):

I was a little surprised that my first attempt of using unsafe { &PROXY[..] } (i.e. just adding [..]) did not work. I had to actually call .as_slice().

region_scope_tree being inferred based on the untyped HIR...

pnkfelix (Jan 06 2020 at 21:01, on Zulip):

hmm okay

pnkfelix (Jan 06 2020 at 21:03, on Zulip):

Anyway my instinct is that if we try to make the generator-transformation more complicated/subtle to handle cases like this, it could be frustrating for users trying to understand what their code is doing.

pnkfelix (Jan 06 2020 at 21:04, on Zulip):

but maybe I'm being paranoid

Matthew Jasper (Jan 06 2020 at 21:04, on Zulip):

So, the reason I think that we can fix this is that the pointer the we create is usually very short lived, it only rarely needs to be captured across a yield.

Matthew Jasper (Jan 06 2020 at 21:06, on Zulip):

But I don't think that HIR typeck really gives us a way to do anything other that what we currently have, or requiring that it's never live across a yield.

Matthew Jasper (Jan 06 2020 at 21:11, on Zulip):

Well, maybe the &PROXY[..] vs. PROXY.as_slice() thing.

pnkfelix (Jan 06 2020 at 21:48, on Zulip):

I guess the right thing at this point is to let the Async-Await WG decide how to handle this?

pnkfelix (Jan 14 2020 at 15:23, on Zulip):

@Matthew Jasper do you plan to invest more time in near term investigating the solution here? I'm just trying to figure out whether I should post a PR to "fix" to the updns crate that was broken by this.

Matthew Jasper (Jan 14 2020 at 19:05, on Zulip):

I'm waiting for feedback to the write up I did.

pnkfelix (Jan 14 2020 at 21:47, on Zulip):

...were there questions in that write up? It was an overview of a couple different trajectories we might take, right?

Matthew Jasper (Jan 14 2020 at 21:50, on Zulip):

Yes, the question is whether we think any of them are with working on.

pnkfelix (Jan 14 2020 at 22:02, on Zulip):

gotcha okay. I'll have to review more carefully. To be honest I wasn't clear about the drawbacks of the MIR internal local approach, but maybe that's because I wasn't clear about the details of that approach in general.

Last update: May 26 2020 at 11:05UTC