summary refs log tree commit diff
path: root/library/alloc/src/sync.rs
AgeCommit message (Collapse)AuthorLines
2023-12-21update 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-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
2023-06-16remove box_free and replace with drop implDrMeepster-9/+7
2023-05-16Fix duplicate `arcinner_layout_for_value_layout` callsmarc0246-6/+19
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
2023-04-26Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadataAlbert Larsan-5/+5
2023-04-12remove some unneeded importsKaDiWa-8/+5
2023-03-23Stabilize `arc_into_inner` and `rc_into_inner`.Frank Steffahn-20/+3
Includes resolving the FIXMEs in the documentation, and some very minor documentation improvements.
2023-03-15unequal → not equalgimbles-2/+2
2023-03-11Rollup merge of #108708 - noamtashma:issue-108706-fix, r=m-ou-seMatthias Krüger-3/+17
Prevent overflow through Arc::downgrade Fixes #108706
2023-03-06issue-108706-fixNoam Ta Shma-3/+17
2023-03-03Match unmatched backticks in library/est31-1/+1
2023-01-29fix typo in {Rc, Arc}::get_mut_unchecked docsy21-1/+1
2023-01-23Rollup merge of #106854 - steffahn:drop_linear_arc_rebased, r=Mark-SimulacrumDylan DPC-0/+145
Add `Arc::into_inner` for safely discarding `Arc`s without calling the destructor on the inner type. ACP: rust-lang/libs-team#162 Reviving #79665. I want to get this merged this time; this does not contain changes (apart from very minor changes in comments/docs). See #79665 for further description of the PR. The only “unresolved” points that led to that PR being closed, AFAICT, were * The desire to also implement a `Rc::into_inner` function * however, this can very well also happen as a subsequent PR * Possible need for further discussion on the naming “`into_inner`” (?) * `into_inner` seems fine to me; also, this PR introduces unstable API, and names can be changed later, too * ~~I don't know if a tracking issue for the feature flag is supposed to be opened before or after this PR gets merged (if *before*, then I can add the issue number to the `#[unstable…]` attribute)~~ There is a [tracking issue](https://github.com/rust-lang/rust/issues/106894) now. I say “unresolved” in quotation marks because from my point of view, if reviewers agree, the PR can be merged immediately and as-is :-)
2023-01-22Add Arc::into_inner for safely discarding Arcs without calling the ↵Frank Steffahn-0/+145
destructor on the inner type. Mainly rebased and squashed from PR rust-lang/rust#79665, furthermore includes minor changes in comments.
2023-01-14Remove various double spaces in source comments.André Vennberg-4/+4
2023-01-08Auto merge of #90291 - geeklint:loosen_weak_debug_bound, r=dtolnaybors-1/+1
Loosen the bound on the Debug implementation of Weak. Both `rc::Weak<T>` and `sync::Weak<T>` currently require `T: Debug` in their own `Debug` implementations, but they don't currently use it; they only ever print a fixed string. A general implementation of Debug for Weak that actually attempts to upgrade and rely on the contents is unlikely in the future because it may have unbounded recursion in the presence of reference cycles, which Weak is commonly used in. (This was the justification for why the current implementation [was implemented the way it is](https://github.com/rust-lang/rust/pull/19388/commits/f0976e2cf3f6b0027f118b791e0888b29fbb41a7)). When I brought it up [on the forum](https://internals.rust-lang.org/t/could-the-bound-on-weak-debug-be-relaxed/15504), it was suggested that, even if an implementation is specialized in the future that relies on the data stored within the Weak, it would likely rely on specialization anyway, and could therefore easily specialize on the Debug bound as well.
2022-12-19Update coerce_unsized tracking issue from #27732 to #18598Anders Kaseorg-2/+2
Issue #27732 was closed as a duplicate of #18598. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-11-20Rollup merge of #101310 - zachs18:rc_get_unchecked_mut_docs_soundness, ↵Matthias Krüger-4/+37
r=Mark-Simulacrum Clarify and restrict when `{Arc,Rc}::get_unchecked_mut` is allowed. (Tracking issue for `{Arc,Rc}::get_unchecked_mut`: #63292) (I'm using `Rc` in this comment, but it applies for `Arc` all the same). As currently documented, `Rc::get_unchecked_mut` can lead to unsoundness when multiple `Rc`/`Weak` pointers to the same allocation exist. The current documentation only requires that other `Rc`/`Weak` pointers to the same allocation "must not be dereferenced for the duration of the returned borrow". This can lead to unsoundness in (at least) two ways: variance, and `Rc<str>`/`Rc<[u8]>` aliasing. ([playground link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d7e2d091c389f463d121630ab0a37320)). This PR changes the documentation of `Rc::get_unchecked_mut` to restrict usage to when all `Rc<T>`/`Weak<T>` have the exact same `T` (including lifetimes). I believe this is sufficient to prevent unsoundness, while still allowing `get_unchecked_mut` to be called on an aliased `Rc` as long as the safety contract is upheld by the caller. ## Alternatives * A less strict, but still sound alternative would be to say that the caller must only write values which are valid for all aliased `Rc`/`Weak` inner types. (This was [mentioned](https://github.com/rust-lang/rust/issues/63292#issuecomment-568284090) in the tracking issue). This may be too complicated to clearly express in the documentation. * A more strict alternative would be to say that there must not be any aliased `Rc`/`Weak` pointers, i.e. it is required that get_mut would return `Some(_)`. (This was also mentioned in the tracking issue). There is at least one codebase that this would cause to become unsound ([here](https://github.com/kaimast/lsm-rs/blob/be5a164d770d850d905e510e2966ad4b1cc9aa5e/src/memtable.rs#L166), where additional locking is used to ensure unique access to an aliased `Rc<T>`; I saw this because it was linked on the tracking issue).
2022-11-18Change undefined-behavior doctests from ignore to no_run.Zachary S-2/+2
2022-11-18Apply suggestions from code review zachs18-1/+1
Fix spelling error.
2022-11-18Add examples to show when `{Arc,Rc}::get_mut_unchecked` is disallowed.Zachary S-0/+32
2022-11-18Clarify and restrict when `{Arc,Rc}::get_mut_unchecked` is allowed.Zachary S-4/+5
2022-11-18Remove Vec/Rc storage reuse optclubby789-54/+6