-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix double drop of allocator in IntoIter impl of Vec #95298
Fix double drop of allocator in IntoIter impl of Vec #95298
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. Please see the contribution instructions for more information. |
Can this include a regression test, perhaps based on orlp's MCVE? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
- (regarding the regression test —which I agree ought to be added—, you can use the drop glue of, for instance, an
Rc
, to know how many times something has been dropped)
Co-authored-by: Daniel Henry-Mantilla <[email protected]>
Thanks for the quick review! I added a test using the existing Github actions have a scheduled maintenance until 16:30 UTC, will check back later for CI results. |
1 similar comment
📌 Commit d9a438d has been approved by |
1 similar comment
📌 Commit d9a438d has been approved by |
…ator-in-vec-into-iter, r=oli-obk Fix double drop of allocator in IntoIter impl of Vec Fixes rust-lang#95269 The `drop` impl of `IntoIter` reconstructs a `RawVec` from `buf`, `cap` and `alloc`, when that `RawVec` is dropped it also drops the allocator. To avoid dropping the allocator twice we wrap it in `ManuallyDrop` in the `InttoIter` struct. Note this is my first contribution to the standard library, so I might be missing some details or a better way to solve this.
…ator-in-vec-into-iter, r=oli-obk Fix double drop of allocator in IntoIter impl of Vec Fixes rust-lang#95269 The `drop` impl of `IntoIter` reconstructs a `RawVec` from `buf`, `cap` and `alloc`, when that `RawVec` is dropped it also drops the allocator. To avoid dropping the allocator twice we wrap it in `ManuallyDrop` in the `InttoIter` struct. Note this is my first contribution to the standard library, so I might be missing some details or a better way to solve this.
…ator-in-vec-into-iter, r=oli-obk Fix double drop of allocator in IntoIter impl of Vec Fixes rust-lang#95269 The `drop` impl of `IntoIter` reconstructs a `RawVec` from `buf`, `cap` and `alloc`, when that `RawVec` is dropped it also drops the allocator. To avoid dropping the allocator twice we wrap it in `ManuallyDrop` in the `InttoIter` struct. Note this is my first contribution to the standard library, so I might be missing some details or a better way to solve this.
Rollup of 6 pull requests Successful merges: - rust-lang#93901 (Stabilize native library modifier syntax and the `whole-archive` modifier specifically) - rust-lang#94806 (Fix `cargo run tidy`) - rust-lang#94869 (Add the generic_associated_types_extended feature) - rust-lang#95011 (async: Give predictable name to binding generated from .await expressions.) - rust-lang#95251 (Reduce max hash in raw strings from u16 to u8) - rust-lang#95298 (Fix double drop of allocator in IntoIter impl of Vec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 6 pull requests Successful merges: - rust-lang#93901 (Stabilize native library modifier syntax and the `whole-archive` modifier specifically) - rust-lang#94806 (Fix `cargo run tidy`) - rust-lang#94869 (Add the generic_associated_types_extended feature) - rust-lang#95011 (async: Give predictable name to binding generated from .await expressions.) - rust-lang#95251 (Reduce max hash in raw strings from u16 to u8) - rust-lang#95298 (Fix double drop of allocator in IntoIter impl of Vec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #95269
The
drop
impl ofIntoIter
reconstructs aRawVec
frombuf
,cap
andalloc
, when thatRawVec
is dropped it also drops the allocator. To avoid dropping the allocator twice we wrap it inManuallyDrop
in theInttoIter
struct.Note this is my first contribution to the standard library, so I might be missing some details or a better way to solve this.