• I also asked about this on Reddit, but will/won’t closures complicate this? At the closure call site you’ll have to insert invalidations based on the body, which comes earlier in the body of the enclosing function. This indicates that you have to work inside-out for the borrow checking as well, so that a closure’s mutations_after_this and revived_after_this are known. Reassigning of closures outside can either replace these (if the assignment happens outside any control flow) or add to these (otherwise).

    It’s not an insurmountable problem by any means, but it does sound like a pure backwards walk won’t be enough, maybe?


    score 1 · canonical

    • Hey! Yeah, closures complicate this. I left another response on reddit too just now, but TL;DR:

      My plan for closures is: When we’re doing phase 3 for a function and we encounter a closure, we gather all the group information of the arguments that we’re feeding to the closure, temporarily suspend borrow checking of the caller, and go do the full phase 3 on the closure, supplying it the parent’s group information, and ultimately calculating the mut effects of the closure.

      That’s the only way to do it that I can see, so far. Luckily, it doesn’t add any more phases, it’s really just suspending one borrow check for another.


      score 1 · canonical