Skip to content

Fix async drop glue for Box<T>#156067

Open
P8L1 wants to merge 1 commit intorust-lang:mainfrom
P8L1:async-drop-box-fix
Open

Fix async drop glue for Box<T>#156067
P8L1 wants to merge 1 commit intorust-lang:mainfrom
P8L1:async-drop-box-fix

Conversation

@P8L1
Copy link
Copy Markdown
Contributor

@P8L1 P8L1 commented May 1, 2026

Fixes #143658.

This fixes async drop behavior for boxed values so that async drop glue reaches the boxed value’s async destructor in async drop context.

The change updates async-drop needs-drop analysis so Box<T> is handled specially for async drop by considering the boxed pointee and allocator when deciding whether async drop glue is needed.

This PR intentionally does not change the broader AsyncDrop design. It only fixes behavior under the existing #![feature(async_drop)] implementation.

Tests:

  • .\x.ps1 test --force-rerun tests/ui/async-await/async-drop/async-drop-box.rs
  • .\x.ps1 test --force-rerun tests/ui/async-await/async-drop
  • .\x.ps1 test tidy

Reviewer notes:

  • async-drop-box-allocator.rs already covers async-dropping the allocator of a Box; this PR adds distinct coverage for the boxed value itself.
  • Boxed dyn pointees are intentionally not pulled into this fix, preserving existing dynamic async-drop limitations.
  • The change is isolated to async drop analysis; sync needs_drop behavior is unchanged.

@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 May 1, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 1, 2026

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 21 candidates

@P8L1

This comment was marked as resolved.

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-gcc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  local time: Fri May  1 22:51:47 UTC 2026
  network time: Fri, 01 May 2026 22:51:47 GMT
##[endgroup]
sccache: Starting the server...
sccache: error: Server startup failed: cache storage failed to read: ConfigInvalid (permanent) at read => S3Error { code: "NoSuchBucket", message: "The specified bucket does not exist", resource: "", request_id: "FAWXCYC6HWXKKT1S" }

Context:
   uri: https://s3.us-west-1.amazonaws.com/rust-lang-ci-sccache2/.sccache_check
   response: Parts { status: 404, version: HTTP/1.1, headers: {"x-amz-request-id": "FAWXCYC6HWXKKT1S", "x-amz-id-2": "ue2j+3Mg5SB98lOJnfKNt161vW//r2C5Mq94hGmkqKDzI+vCq0AxVuZNWK0R6F0vohb03Js1OcUZIDp+S8kd1v4ItuydyO7a", "content-type": "application/xml", "transfer-encoding": "chunked", "date": "Fri, 01 May 2026 22:51:47 GMT", "server": "AmazonS3"} }
   service: s3
   path: .sccache_check
   range: 0-

Backtrace:
---
[TIMING:end] compile::StdLink { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, crates: [], force_recompile: false } -- 0.002
##[group]Building stage1 compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
error: process didn't exit successfully: `sccache /checkout/obj/build/bootstrap/debug/rustc -vV` (exit status: 2)
--- stderr
sccache: error: Server startup failed: cache storage failed to read: ConfigInvalid (permanent) at read => S3Error { code: "NoSuchBucket", message: "The specified bucket does not exist", resource: "", request_id: "PGSYMS51QBTC95RA" }

Context:
   uri: https://s3.us-west-1.amazonaws.com/rust-lang-ci-sccache2/.sccache_check
   response: Parts { status: 404, version: HTTP/1.1, headers: {"x-amz-request-id": "PGSYMS51QBTC95RA", "x-amz-id-2": "uyUthBKZ3lKFhCXTlxD9W5+W/MwmVyfRo5X69GLRFdf/WEu+W37tVD1I1zydDw82QiP7ZrQexls7mhcZec946JsHFFLE04hp", "content-type": "application/xml", "transfer-encoding": "chunked", "date": "Fri, 01 May 2026 22:52:52 GMT", "server": "AmazonS3"} }
   service: s3
   path: .sccache_check
   range: 0-

Backtrace:
---
  11: <unknown>
  12: <unknown>


Run with SCCACHE_LOG=debug SCCACHE_NO_DAEMON=1 to get more information

Bootstrap failed while executing `--stage 2 test tests --test-codegen-backend gcc --skip tests/coverage --skip tests/coverage-run-rustdoc --skip tests/rustdoc-html --skip tests/rustdoc-gui --skip tests/rustdoc-js --skip tests/rustdoc-js-std --skip tests/rustdoc-json --skip tests/rustdoc-ui --set rust.codegen-backends=["llvm","gcc"]`
Build completed unsuccessfully in 0:00:29
  local time: Fri May  1 22:52:52 UTC 2026
  network time: Fri, 01 May 2026 22:52:52 GMT

For more information how to resolve CI failures of this job, visit this link.

@Kivooeo Kivooeo closed this May 1, 2026
@Kivooeo Kivooeo reopened this May 1, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 1, 2026
@oli-obk

This comment was marked as resolved.

@P8L1

This comment was marked as resolved.

@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented May 3, 2026

oof turns out I didn't see #145316 for 9 months. Gonna review that one first

@oli-obk oli-obk added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label May 3, 2026
@P8L1
Copy link
Copy Markdown
Contributor Author

P8L1 commented May 3, 2026

oof turns out I didn't see #145316 for 9 months. Gonna review that one first

LMAO Ok gl

@oli-obk oli-obk removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-blocked Status: Blocked on something else such as an RFC or other implementation work. 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.

AsyncDrop not called when type is inside Box

5 participants