-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 some Arc
allocator leaks
#120445
Fix some Arc
allocator leaks
#120445
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
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.
r=me with nit fixed (or if I missed something and it can't be fixed then also fine to approve)
@@ -3443,8 +3445,8 @@ impl<T, A: Allocator + Clone, const N: usize> TryFrom<Arc<[T], A>> for Arc<[T; N | |||
|
|||
fn try_from(boxed_slice: Arc<[T], A>) -> Result<Self, Self::Error> { | |||
if boxed_slice.len() == N { | |||
let alloc = boxed_slice.alloc.clone(); | |||
Ok(unsafe { Arc::from_raw_in(Arc::into_raw(boxed_slice) as *mut [T; N], alloc) }) | |||
let (ptr, alloc) = boxed_slice.internal_into_inner_with_allocator(); |
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.
In the cases above you also removed the A: Clone
bound -- seems like we ought to do that here too?
@bors r=Mark-Simulacrum |
@bors r- |
Whoops, missed the impl that was actually commenting on. |
This doesn't matter for the stable `Global` allocator as it is a ZST singleton, but other allocators may rely on all instances being dropped.
@bors r=Mark-Simulacrum |
…llaumeGomez Rollup of 11 pull requests Successful merges: - rust-lang#117906 (Improve display of crate name when hovered) - rust-lang#118533 (Suppress unhelpful diagnostics for unresolved top level attributes) - rust-lang#120293 (Deduplicate more sized errors on call exprs) - rust-lang#120295 (Remove `raw_os_nonzero` feature.) - rust-lang#120310 (adapt test for v0 symbol mangling) - rust-lang#120342 (Remove various `has_errors` or `err_count` uses) - rust-lang#120434 (Revert outdated version of "Add the wasm32-wasi-preview2 target") - rust-lang#120445 (Fix some `Arc` allocator leaks) - rust-lang#120475 (Improve error message when `cargo build` is used to build the compiler) - rust-lang#120476 (Remove some unnecessary check logic for lang items in HIR typeck) - rust-lang#120485 (add missing potential_query_instability for keys and values in hashmap) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120445 - Nemo157:arc-plug, r=Mark-Simulacrum Fix some `Arc` allocator leaks This doesn't matter for the stable `Global` allocator as it is a ZST singleton, but other allocators may rely on all instances being dropped.
… r=Mark-Simulacrum Relax allocator requirements on some Rc/Arc APIs. Split out from rust-lang#119761 * Remove `A: Clone` bound from `Rc::assume_init`(s), `Rc::downcast`, and `Rc::downcast_unchecked` (`Arc` methods were already relaxed by rust-lang#120445) * Make `From<Rc<[T; N]>> for Rc<[T]>` allocator-aware (`Arc`'s already is). * Remove `A: Clone` from `Rc/Arc::unwrap_or_clone` Internal changes: * Made `Arc::internal_into_inner_with_allocator` method into `Arc::into_inner_with_allocator` associated fn. * Add private `Rc::into_inner_with_allocator` (to match Arc), so other fns don't have to juggle `ManuallyDrop`.
… r=Mark-Simulacrum Relax allocator requirements on some Rc/Arc APIs. Split out from rust-lang#119761 * Remove `A: Clone` bound from `Rc::assume_init`(s), `Rc::downcast`, and `Rc::downcast_unchecked` (`Arc` methods were already relaxed by rust-lang#120445) * Make `From<Rc<[T; N]>> for Rc<[T]>` allocator-aware (`Arc`'s already is). * Remove `A: Clone` from `Rc/Arc::unwrap_or_clone` Internal changes: * Made `Arc::internal_into_inner_with_allocator` method into `Arc::into_inner_with_allocator` associated fn. * Add private `Rc::into_inner_with_allocator` (to match Arc), so other fns don't have to juggle `ManuallyDrop`.
… r=Mark-Simulacrum Relax allocator requirements on some Rc/Arc APIs. Split out from rust-lang#119761 * Remove `A: Clone` bound from `Rc::assume_init`(s), `Rc::downcast`, and `Rc::downcast_unchecked` (`Arc` methods were already relaxed by rust-lang#120445) * Make `From<Rc<[T; N]>> for Rc<[T]>` allocator-aware (`Arc`'s already is). * Remove `A: Clone` from `Rc/Arc::unwrap_or_clone` Internal changes: * Made `Arc::internal_into_inner_with_allocator` method into `Arc::into_inner_with_allocator` associated fn. * Add private `Rc::into_inner_with_allocator` (to match Arc), so other fns don't have to juggle `ManuallyDrop`.
Rollup merge of rust-lang#124981 - zachs18:rc-allocator-generalize-1, r=Mark-Simulacrum Relax allocator requirements on some Rc/Arc APIs. Split out from rust-lang#119761 * Remove `A: Clone` bound from `Rc::assume_init`(s), `Rc::downcast`, and `Rc::downcast_unchecked` (`Arc` methods were already relaxed by rust-lang#120445) * Make `From<Rc<[T; N]>> for Rc<[T]>` allocator-aware (`Arc`'s already is). * Remove `A: Clone` from `Rc/Arc::unwrap_or_clone` Internal changes: * Made `Arc::internal_into_inner_with_allocator` method into `Arc::into_inner_with_allocator` associated fn. * Add private `Rc::into_inner_with_allocator` (to match Arc), so other fns don't have to juggle `ManuallyDrop`.
This doesn't matter for the stable
Global
allocator as it is a ZST singleton, but other allocators may rely on all instances being dropped.