Can we reduce the burden of cancel-correctness for async Futures?

What would the rules around a language defer be?

(Potential weak keyword usage of defer: make it a prefix keyword that takes a closure-like argument: defer || { .. }. This avoids the issue of defer { } being ambiguous when defer can be a structure name. Using a real keyword, make it a final { .. }.)

I’m not sure exactly how this would be modeled in HIR/MIR, but I think the semantics we’d want is that the code is stuck into the “drop glue” section of the cleanup path before MIR borrowcheck is run, assuming MIR borrowcheck even looks at drop glue, so that borrowcheck can see that the mutable borrow doesn’t require a lock for the whole function, just that the place exists and isn’t aliased on drop.

2 Likes