We can't enable lambda lifting because some of our tests have free variables in lambda functions.
To handle mutated free variables in lambdas, we do an additional prepass
that transforms turns modified free variables into use of a &mut free variable. A minimal
transformation is as follows:
|x| { c = x; e }
===>
{ let ac = &mut c; |x| { let c = move *ac; let res = { c = x; e }; *ac = move c; res } }
after which, the lambda has no mutated free variables and can be replaced by Closure(lifted, ac).
Now, what borrow analysis can do with that remains to be seen. We may want to do something
special if the lambda already uses &mut c for free variable c.
🚀 Feature Request
We can't enable lambda lifting because some of our tests have free variables in lambda functions.
To handle mutated free variables in lambdas, we do an additional prepass that transforms turns modified free variables into use of a
&mut
free variable. A minimal transformation is as follows:after which, the lambda has no mutated free variables and can be replaced by Closure(lifted, ac).
Now, what borrow analysis can do with that remains to be seen. We may want to do something special if the lambda already uses
&mut c
for free variablec
.