-
Notifications
You must be signed in to change notification settings - Fork 385
miri doesn't drop values moved into closures with let _ = x
#135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@oli-obk Weird... the closure body ought to explicitly drop the closure environment argument in MIR. |
I figured out the problem here.
Our shim acts like the following function, where fn call_once_shim(self) {
body(&self)
// NOTE: self should be dropped at the end of scope, but Miri doesn't do it.
} As you can see in the shim code I linked above, we do add this |
Note that if you force the closure to by-value use a separate value to remove Miri's use of the shim, then the closure's drop glue is properly called, as in this test I added. EDIT: Actually I think in that case the closure body itself will drop EDIT 2: ...which I guess means the closure body executes the closure's drop glue, so I wasn't wrong, just imprecise. :P |
Great analysis! I'll take this bug, drop code is my fault anyway ;) |
The following code works fine if
drop(x)
is used instead oflet _ = x
. The closure function generated contains just a_0 = ()
and areturn
. Trans probably does some magic, but I haven't been able to locate it.The text was updated successfully, but these errors were encountered: