Skip to content

Have arrays' drop_glue just unsize and call the slice version#155184

Draft
scottmcm wants to merge 10 commits intorust-lang:mainfrom
scottmcm:intercept-array-drop-shim
Draft

Have arrays' drop_glue just unsize and call the slice version#155184
scottmcm wants to merge 10 commits intorust-lang:mainfrom
scottmcm:intercept-array-drop-shim

Conversation

@scottmcm
Copy link
Copy Markdown
Member

@scottmcm scottmcm commented Apr 12, 2026

It's silly to emit two loops (because of the drop ladder -- just one in panic=abort) for every array length that's dropped when we can just polymorphize to the slice version.

Built atop #154327 to avoid conflicts later, so draft for now.

r? @WaffleLapkin

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 12, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 12, 2026

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

@scottmcm scottmcm added I-heavy Issue: Problems and improvements with respect to binary size of generated code. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. PG-exploit-mitigations Project group: Exploit mitigations A-run-make Area: port run-make Makefiles to rmake.rs A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` labels Apr 12, 2026

// RAW: ; core::ptr::drop_glue::<[array_drop_glue::NeedsDrop; [[N:7|13|42]]]>
// RAW-NEXT: inlinehint
// RAW: call core::ptr::drop_glue::<[array_drop_glue::NeedsDrop]>
Copy link
Copy Markdown
Member Author

@scottmcm scottmcm Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

Compare nightly https://rust.godbolt.org/z/5Wv1q86ja with a loop in each of the three.

@rust-log-analyzer

This comment has been minimized.

@WaffleLapkin
Copy link
Copy Markdown
Member

💭 does it make sense to keep the array case separate for N <= 1 or something?

@scottmcm
Copy link
Copy Markdown
Member Author

My understanding is that LLVM will very effectively inline those -- just like how we don't special case the array iterator for N ≤ 1 and still use the polymorphic version.

Does make me ponder if we should have a separate general "hey, there's no Drop so we can delegate to the one for the one field" kind of check, but I'd leave all these for a different PR if that's ok.

@scottmcm scottmcm force-pushed the intercept-array-drop-shim branch from d1bdee8 to 2ae092a Compare April 15, 2026 01:23
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Apr 15, 2026
@rustbot rustbot added A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` PG-exploit-mitigations Project group: Exploit mitigations labels Apr 15, 2026
@scottmcm scottmcm removed PG-exploit-mitigations Project group: Exploit mitigations A-run-make Area: port run-make Makefiles to rmake.rs A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` labels Apr 15, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 17, 2026

☔ The latest upstream changes (presumably #155207) made this pull request unmergeable. Please resolve the merge conflicts.

@scottmcm scottmcm added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-heavy Issue: Problems and improvements with respect to binary size of generated code. S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants