Skip to content

Drop remaining ZSTs if array mapping fails#152220

Open
eggyal wants to merge 2 commits intorust-lang:mainfrom
eggyal:drop-zsts-in-aborted-array-map
Open

Drop remaining ZSTs if array mapping fails#152220
eggyal wants to merge 2 commits intorust-lang:mainfrom
eggyal:drop-zsts-in-aborted-array-map

Conversation

@eggyal
Copy link
Copy Markdown
Contributor

@eggyal eggyal commented Feb 6, 2026

Dropping the Drain used by the array::[try_]map functions should drop any pending elements, whether they are ZST or not.

Fixes #152211
r? libs

Dropping the `Drain` used by the `array::[try_]map` functions should
drop any pending elements, whether they are ZST or not.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 6, 2026
Comment thread library/core/src/array/drain.rs Outdated
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 27, 2026
core: drop unmapped ZSTs in array `map`

Fixes rust-lang#152211.
Alternative to rust-lang#152220 and rust-lang#152248.

This makes the `Drain` type use the same ZST-handling strategy as `slice::IterMut`, which stores the remaining length instead of a one-past-the-end pointer when the type is a ZST. I've also removed the const-generic `N` parameter from `Drain` to avoid unnecessary monomorphizations.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 27, 2026
core: drop unmapped ZSTs in array `map`

Fixes rust-lang#152211.
Alternative to rust-lang#152220 and rust-lang#152248.

This makes the `Drain` type use the same ZST-handling strategy as `slice::IterMut`, which stores the remaining length instead of a one-past-the-end pointer when the type is a ZST. I've also removed the const-generic `N` parameter from `Drain` to avoid unnecessary monomorphizations.
rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
core: drop unmapped ZSTs in array `map`

Fixes #152211.
Alternative to #152220 and #152248.

This makes the `Drain` type use the same ZST-handling strategy as `slice::IterMut`, which stores the remaining length instead of a one-past-the-end pointer when the type is a ZST. I've also removed the const-generic `N` parameter from `Drain` to avoid unnecessary monomorphizations.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 1, 2026
core: drop unmapped ZSTs in array `map`

Fixes rust-lang#152211.
Alternative to rust-lang#152220 and rust-lang#152248.

This makes the `Drain` type use the same ZST-handling strategy as `slice::IterMut`, which stores the remaining length instead of a one-past-the-end pointer when the type is a ZST. I've also removed the const-generic `N` parameter from `Drain` to avoid unnecessary monomorphizations.
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-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

array::map and array::try_map do not drop ZSTs properly

4 participants