summary refs log tree commit diff
path: root/library/alloc/src/rc.rs
AgeCommit message (Collapse)AuthorLines
2024-04-27Relax `A: Clone` bound for `rc::Weak::into_raw_and_alloc`Daria Sukhonina-7/+4
2024-04-12Auto merge of #120092 - zetanumbers:pin_in_static_allocator, r=Amanieubors-1/+4
Add `A: 'static` bound for `Arc/Rc::pin_in` Analogous to https://github.com/rust-lang/rust/pull/79327 Needed to preserve pin's [drop guarantee](https://doc.rust-lang.org/std/pin/index.html#drop-guarantee)
2024-03-25Require DerefPure for patternsMichael Goulet-1/+4
2024-03-05Rollup merge of #121287 - zachs18:rc-into-raw-must-use, r=cuviperMatthias Krüger-1/+2
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-03-05Rollup merge of #121213 - Takashiidobe:takashi/example-for-rc-into-inner, ↵Matthias Krüger-0/+15
r=cuviper Add an example to demonstrate how Rc::into_inner works This PR adds an example to Rc::into_inner, since it didn't have one previously.
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/+2
2024-02-16Add an example to demonstrate how Rc::into_inner worksTakashiidobe-0/+15
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-29Rollup merge of #120266 - steffahn:a_rc_into_inner_docs, r=Mark-SimulacrumDylan DPC-2/+5
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 doctestJohn-John Tedro-2/+3
2024-01-28Replicate documentation in {Rc,Arc}::from_raw_inJohn-John Tedro-9/+34
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-11/+16
rc,sync: Do not create references to uninitialized values Closes #119241 r? `@RalfJung`
2024-01-23Improve documentation for [A]Rc::into_innerFrank Steffahn-2/+5
General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap.
2024-01-23Auto merge of #119892 - joboet:libs_use_assert_unchecked, r=Nilstrieb,cuviperbors-2/+3
Use `assert_unchecked` instead of `assume` intrinsic in the standard library Now that a public wrapper for the `assume` intrinsic exists, we can use it in the standard library. CC #119131
2024-01-18Add `A: 'static` bound for `Arc/Rc::pin_in`zetanumbers-1/+4
2024-01-13libs: use `assert_unchecked` instead of intrinsicjoboet-2/+3
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-11/+16
2023-12-30rc: Take *const T in is_danglingTaiki Endo-2/+2
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-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-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-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-08-22Replace version placeholders with 1.73.0Mark Rousskov-1/+1
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-08-03Fix documentation of Rc as From<Vec<T>>July Tikhonov-3/+3
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-138/+749
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
2023-06-19Introduce `alloc::::UniqueRc`Eric Holk-3/+139
This is an `Rc` that is guaranteed to only have one strong reference. Because it is uniquely owned, it can safely implement `DerefMut`, which allows programs to have an initialization phase where structures inside the `Rc` can be mutated. The `UniqueRc` can then be converted to a regular `Rc`, allowing sharing and but read-only access. During the "initialization phase," weak references can be created, but attempting to upgrade these will fail until the `UniqueRc` has been converted to a regular `Rc`. This feature can be useful to create cyclic data structures. This API is an implementation based on the feedback provided to the ACP at https://github.com/rust-lang/libs-team/issues/90.
2023-06-16remove box_free and replace with drop implDrMeepster-9/+7
2023-05-08Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, ↵bors-1/+1
r=Mark-Simulacrum enable `rust_2018_idioms` lint group for doctests With this change, `rust_2018_idioms` lint group will be enabled for compiler/libstd doctests. Resolves #106086 Resolves #99144 Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-07enable `rust_2018_idioms` for doctestsozkanonur-1/+1
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-04-28replace version placeholdersPietro Albini-1/+1