Open zetanumbers opened 3 weeks ago
Indeed, you define a smart way to leak the local reference to a thread. However this is not a normal use case for std::thread::scope
.
I think we should enforce the scoped coroutine type not forgettable, but currently rust doesn't support that mechenism.
I think we should enforce the scoped coroutine type not forgettable, but currently rust doesn't support that mechenism.
That's how I have come to this code sample, I've assumed the generator should implement negative of any auto trait due to inability to analyze local variables within a generator, which would include the missing Forget
trait.
However this is not a normal use case for
std::thread::scope
.
I use roughly the same mechanism as with std::thread::scope
in the scope-lock library for lifetime extension, which I think is quite often desirable. Basically the example from the top message implements one way longjmp which I think can be reasonably deemed unsafe or UB cause.
https://hackmd.io/@wg-async/S1Q6Leam0?utm_source=preview-mode&utm_medium=rec
Hey, that's actually my proposal! 😄 I appreciate this reference.
Prints out:
Similar to https://github.com/Amanieu/corosensei/issues/27