-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Missing drop in FnOnce adapter for closures #29946
Comments
cc @pnkfelix I think I've seen this before, happens with other traits as well. |
triage: P-medium |
1 similar comment
triage: P-medium |
This appears to only happen if 1. the closure is called via a generic function, and 2. the captured variable is not explicitly moved into the closure body. If "let a = x;" is used in place of calling a borrowing method, the destructor is called. |
Preliminary investigation - The cause is from the closure not being treated as FnOnce when destructor calls are added to the "body" (in This is exposed when the closure is explicitly called as Routes to fixing:
|
|
I don't think the shim is used here. |
I'm reasonably sure it is. It is being run, and registers |
fcx.pop_custom_cleanup_scope(self_scope); to fcx.pop_and_trans_custom_cleanup_scope(bcx, self_scope); Leads to my test case passing. I'm running the full test suite now in preparation for a PR. |
trans::meth is such a hack |
What do you mean by that? |
PR with fix filed #31462 - Running full local tests at the moment, stage1 passed |
Generates drop calls at the end of the Fn/FnMut -> FnOnce closure shim Fix #29946
playpen
Somehow, the Foo object leaks: my guess is that it has something to do with the way we generate code for the
FnOnce()
trait for closures which also implementFn()
.Originally reported at #28796 (comment) .
The text was updated successfully, but these errors were encountered: