Skip to content

Fix Box allocator drop elaboration #143672

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

beepster4096
Copy link
Contributor

@beepster4096 beepster4096 commented Jul 9, 2025

New version of #131146.

Clearing Box's drop flag after running its destructor can cause it to skip dropping its allocator, so just don't. Its cleared by the drop ladder code afterwards already.

Unlike the last PR this also handles other types with destructors properly, in the event that we can have open drops on them in the future (by partial initialization or DerefMove or something).

Finally, I also added tests for the interaction with async drop here but I discovered #143658, so one of the tests has a knownbug annotation. Not sure if it should be in this PR at all though.

Fixes #131082

r? wesleywiser - prev. reviewer

@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2025

wesleywiser is not on the review rotation at the moment.
They may take a while to respond.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@beepster4096
Copy link
Contributor Author

r? compiler since wesleywiser is off rotation

@rustbot rustbot assigned WaffleLapkin and unassigned wesleywiser Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Box sometimes forgets to drop its allocator when the Box is conditionally initialized.
4 participants