oli yes, that would be acceptable, I think, but would involve some more manipulation of the AST which seemed unnecessary. (that is, this seemed the simpler solution, at no noteworthy performance hit.)
the advantage of the local variable is (I believe) that you can get rid of the closure entirely, and reuse https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html#method.entry_fn
that's true, I think, but beyond the above benefit, the closure serves as a nice compartmentalisation of the "user fn", since there would be statements after it in
main in any case (and in the future, possibly even before)
oh, diagnostics again, right
otherwise you may get errors/warnings about things you didn't write
but the other point I was thinking of: with the closure, it's very straightforward for the miri evaluator to detect when the "user fn" is done with, and the locals' memory can be saved (and not any other locals in
main, which shouldn't be saved).
cool, glad this is clear now.
Thanks for explaining it