-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Vec::into_boxed_slice no-excess guarantee regressed in 1.77.0 #125941
Copy link
Copy link
Open
Labels
A-boxArea: Our favorite opsem complicationArea: Our favorite opsem complicationA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.Category: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-boxArea: Our favorite opsem complicationArea: Our favorite opsem complicationA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.Category: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
#36284 asked for clarity about how to use
Box<[T]>::into_raw. The core issue was that the documentation forVec::into_boxed_slicesaid it reduced excess capacity in a way that was equivalent to callingVec::shrink_to_fit. However, the latter makes no guarantees about there being no excess capacity afterwards. The resolution of #36284 (specifically in #36284 (comment)) was forVec::into_boxed_sliceto itself guarantee that it results in an exact allocation with no excess capacity, and to decouple it fromVec::shrink_to_fit. The documentation was updated to reflect this guarantee in #44960.#120110 reintroduced the equivalence to
Vec::shrink_to_fit, and removed the guarantee by removing this language:I note however that the PR did not update the example, which still appears to encode the intention of the guarantee (it checks the post-shrinking capacity is exactly the length, vs the corresponding example in
Vec::shrink_to_fitwhich checks the post-shrinking capacity is at least the length).As such, it is unclear whether this guarantee regression was intentional or not. But as things currently stand, we are back in a position where
Box<[T]>::into_rawis functionally useless.Version with regression
#120110 was merged during the 1.77.0 cycle.