about summary refs log tree commit diff
path: root/library/alloc/src/sync.rs
AgeCommit message (Collapse)AuthorLines
2024-03-19SeqCst->Relaxed in doc examples.Mara Bos-1/+1
SeqCst is unnecessary here.
2024-03-05Rollup merge of #121287 - zachs18:rc-into-raw-must-use, r=cuviperMatthias Krüger-1/+1
Clarify/add `must_use` message for Rc/Arc/Weak::into_raw. The current `#[must_use]` messages for `{sync,rc}::Weak::into_raw` ("`self` will be dropped if the result is not used") are misleading, as `self` is consumed and will *not* be dropped. This PR changes their `#[must_use]` message to the same as `Arc::into_raw`'s[ current `#[must_use]` message](https://github.com/rust-lang/rust/blob/d5735645753e990a72446094f703df9b5e421555/library/alloc/src/sync.rs#L1482) ("losing the pointer will leak memory"), and also adds it to `Rc::into_raw`, which is not currently `#[must_use]`.
2024-02-24library: use `addr_of!`Pavel Grigorenko-2/+2
2024-02-21rename ptr::invalid -> ptr::without_provenanceRalf Jung-2/+6
also introduce ptr::dangling matching NonNull::dangling
2024-02-18Clarify/add `must_use` message for Rc/Arc/Weak::into_raw.Zachary S-1/+1
2024-02-15Rollup merge of #120449 - udoprog:document-unsized-rc-arc-from-raw, r=m-ou-seGuillaume Gomez-13/+61
Document requirements for unsized {Rc,Arc}::from_raw This seems to be implied due to these types supporting operation-less unsized coercions. Taken together with the [established behavior of a wide to thin pointer cast](https://github.com/rust-lang/reference/pull/1451) it would enable unsafe downcasting of these containers. Note that the term "data pointer" is adopted from https://github.com/rust-lang/rfcs/pull/3559 See also this [internals thread](https://internals.rust-lang.org/t/can-unsafe-smart-pointer-downcasts-be-correct/20229/2).
2024-01-30Rollup merge of #120445 - Nemo157:arc-plug, r=Mark-SimulacrumGuillaume Gomez-24/+20
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.
2024-01-29Rollup merge of #120266 - steffahn:a_rc_into_inner_docs, r=Mark-SimulacrumDylan DPC-3/+7
Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from https://github.com/rust-lang/rust/issues/106894#issuecomment-1905627234. Rendered: ![Screenshot_20240123_114436](https://github.com/rust-lang/rust/assets/3986214/68896d62-13e0-4f3a-8073-91d8e77c5554) ![Screenshot_20240123_114455](https://github.com/rust-lang/rust/assets/3986214/dc58e4bd-dd7f-40b1-bc50-fd6200dde593)
2024-01-28Fix some `Arc` allocator leaksWim Looman-24/+20
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.
2024-01-28Fix doctestJohn-John Tedro-2/+3
2024-01-28Replicate documentation in {Rc,Arc}::from_raw_inJohn-John Tedro-7/+32
2024-01-28Fix doctestJohn-John Tedro-2/+2
2024-01-28Tidy upJohn-John Tedro-1/+1
2024-01-28Add examples for unsized {Rc,Arc}::from_rawJohn-John Tedro-0/+14
2024-01-28Document requirements for unsized {Rc,Arc}::from_rawJohn-John Tedro-6/+14
2024-01-23Auto merge of #119433 - taiki-e:rc-uninit-ref, r=Nilstriebbors-9/+9
rc,sync: Do not create references to uninitialized values Closes #119241 r? `@RalfJung`
2024-01-23Improve documentation for [A]Rc::into_innerFrank Steffahn-3/+7
General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap.
2024-01-18Add `A: 'static` bound for `Arc/Rc::pin_in`zetanumbers-2/+8
2024-01-10Fix deallocation with wrong allocator in (A)Rc::from_box_inzachs18-1/+1
2024-01-08rc,sync: Do not create references to uninitialized valuesTaiki Endo-9/+9
2024-01-03Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-SimulacrumLeón Orell Valerian Liehr-1/+1
rc: Take *const T in is_dangling It is not important which one is used since `is_dangling` does not access memory, but `*const` removes the needs of `*const T` -> `*mut T` casts in `from_raw_in`.
2023-12-30Rollup merge of #119158 - JohnTheCoolingFan:arc-weak-clone-pretty, r=cuviperMatthias Krüger-14/+11
Clean up alloc::sync::Weak Clone implementation Since both return points (tail and early return) return the same expression and the only difference is whether inner is available, the code that does the atomic operations and checks on inner was moved into the if body and the only return is at the tail. Original comments preserved.
2023-12-30rc: Take *const T in is_danglingTaiki Endo-1/+1
It is not important which one is used since `is_dangling` does not access memory, but `*const` removes the needs of `*const T` -> `*mut T` casts in `from_raw_in`.
2023-12-22update version placeholdersPietro Albini-1/+1
2023-12-20Cleaned up alloc::sync::Weak Clone implementationJohnTheCoolingFan-14/+11
Since both return points (tail and early return) return the same expression and the only difference is whether inner is available, the code that does the atomic operations and checks on inner was moved into the if body and the only return is at the tail. Original comments preserved.
2023-12-10Auto merge of #116949 - hamza1311:stablize-arc_unwrap_or_clone, r=dtolnaybors-2/+1
Stablize arc_unwrap_or_clone Fixes: #93610 This likely needs FCP. I created this PR as it's stabilization is trivial and FCP can be just conducted here. Not sure how to ping the libs API team (last attempt didn't work apparently according to GH UI)
2023-12-07Auto merge of #117960 - zhiqiangxu:dry, r=workingjubileebors-5/+3
chore: avoid duplicate code in `Weak::inner`
2023-12-06Don't repeat yourselfzhiqiangxu-5/+3
2023-11-28Add proper cfgsr0cky-0/+1
2023-10-19Stablize arc_unwrap_or_cloneMuhammad Hamza-2/+1
2023-10-14Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkanbors-3/+3
Bump bootstrap compiler to just-released beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-10-08Bump to latest betaMark Rousskov-2/+2
2023-10-05Add more diagnostic items for clippyJason Newcomb-0/+1
2023-10-03Bump version placeholdersMark Rousskov-1/+1
2023-10-02Use `addr_eq` in `{Arc,Rc}::ptr_eq`Scott McMurray-2/+2
Since it's made for stuff like this (see 106447)
2023-09-30Auto merge of #115546 - SUPERCILEX:patch-2, r=Amanieubors-4/+4
Weaken needlessly restrictive orderings on Arc::*_count Follow up to https://github.com/rust-lang/rust/pull/95183 from this zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Why.20does.20Arc.3A.3Astrong_count.20use.20Acquire.20instead.20of.20Relaxed.3F/near/386213850 I'd like to use the strong_count for a lockless algorithm I'm writing, but I don't need acquire semantics so that's pointlessly restrictive on arm/risc-v.
2023-09-28Auto merge of #114041 - nvzqz:nvzqz/shared_from_array, r=dtolnaybors-0/+21
Implement `From<[T; N]>` for `Rc<[T]>` and `Arc<[T]>` Given that `Box<[T]>` already has this conversion, the shared counterparts should also have it.
2023-09-16Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726bors-0/+2
Make useless_ptr_null_checks smarter about some std functions This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc. This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`). Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null. Follow-up of PR #113657 Fixes #114442
2023-09-04Weaken needlessly restrictive orderings on Arc::*_countAlex Saveau-4/+4
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-08-22Replace version placeholders with 1.73.0Mark Rousskov-1/+1
2023-08-18relax redundancy constraintKyle Lin-4/+2
2023-08-13core/any: remove Provider traitwayne warren-1/+1
* remove `impl Provider for Error` * rename `Demand` to `Request` * update docstrings to focus on the conceptual API provided by `Request` * move `core::any::{request_ref, request_value}` functions into `core::error` * move `core::any::tag`, `core::any::Request`, an `core::any::TaggedOption` into `core::error` * replace `provide_any` feature name w/ `error_generic_member_access` * move `core::error::request_{ref,value} tests into core::tests::error module * update unit and doc tests
2023-08-06Add #[rustc_never_returns_null_ptr] to std functionsest31-0/+2
Add the attribute to standard library functions that are guaranteed to never return null pointers, as their originating data wouldn't allow it.
2023-07-30Rollup merge of #95965 - CAD97:const-weak-new, r=workingjubileeJubilee-1/+1
Stabilize const-weak-new This is a fairly uncontroversial library stabilization, so I'm going ahead and proposing it to ride the trains to stable. This stabilizes the following APIs, which are defined to be non-allocating constructors. ```rust // alloc::rc impl<T> Weak<T> { pub const fn new() -> Weak<T>; } // alloc::sync impl<T> Weak<T> { pub const fn new() -> Weak<T>; } ``` Closes #95091 ``@rustbot`` modify labels: +needs-fcp
2023-07-30Stabilize const-weak-newCAD97-1/+1
Bump its stabilization version several times along the way to accommodate changes in release processes. Co-authored-by: Mara Bos <m-ou.se@m-ou.se> Co-authored-by: Trevor Gross <t.gross35@gmail.com>
2023-07-24Implement `From<[T; N]>` for `Rc<[T]>` and `Arc<[T]>`Nikolai Vazquez-0/+21
2023-07-18Make {Rc,Arc}::allocator associated functionsMike Hommey-2/+6
2023-06-30Add support for allocators in `Rc` and `Arc`Cyborus04-1/+1
2023-06-30Add support for allocators in `Rc` and `Arc`Cyborus04-162/+769
2023-06-21Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieubors-5/+5
Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata FCP completed in https://github.com/rust-lang/rust/issues/103763#issuecomment-1362267967 Closes #103763