summary refs log tree commit diff
path: root/src/liballoc/sync.rs
AgeCommit message (Collapse)AuthorLines
2019-06-16make `Weak::ptr_eq`s into methodsThomas Heck-7/+7
2019-06-13docs: Use String in Rc::into_raw examplesMichal 'vorner' Vaner-14/+14
It is unclear if accessing an integer after `drop_in_place` has been called on it is undefined behaviour or not, as demonstrated by the discussion in https://github.com/rust-lang/rust/pull/60766#pullrequestreview-243414222. Avoid these uncertainties by using String which frees memory in its `drop_in_place` to make sure this is undefined behaviour. The message in the docs should be to watch out and not access the data after that, not discussing when one maybe could get away with it O:-).
2019-05-26sync::Weak::{as,from,into}_rawMichal 'vorner' Vaner-6/+158
Methods on the Weak to access it as raw pointer to the data.
2019-05-11add comment to `Rc`/`Arc`'s `Eq` specializationThomas Heck-0/+5
2019-04-18make liballoc internal test suite mostly pass in MiriRalf Jung-0/+2
2019-02-10libs: doc commentsAlexander Regueiro-4/+4
2019-02-03liballoc: revert nested imports style changes.Mazdak Farrokhzad-42/+36
2019-02-02liballoc: fix some idiom lints.Mazdak Farrokhzad-4/+4
2019-02-02liballoc: elide some lifetimes.Mazdak Farrokhzad-2/+2
2019-02-02liballoc: adjust abolute imports + more import fixes.Mazdak Farrokhzad-2/+1
2019-02-02liballoc: refactor & fix some imports.Mazdak Farrokhzad-39/+42
2019-02-02liballoc: cargo check passes on 2018Mazdak Farrokhzad-5/+5
2019-01-31Auto merge of #56696 - jonas-schievink:weak-counts, r=alexcrichtonbors-1/+83
Implement Weak::{strong_count, weak_count} The counters are also useful on `Weak`, not just on strong references (`Rc` or `Arc`). In situations where there are still strong references around, you can also get these counts by temporarily upgrading and adjusting the values accordingly. Using the methods introduced here is simpler to do, less error-prone (since you can't forget to adjust the counts), can also be used when no strong references are around anymore, and might be more efficient due to not having to temporarily create an `Rc`. This is mainly useful in assertions or tests of complex data structures. Data structures might have internal invariants that make them the sole owner of a `Weak` pointer, and an assertion on the weak count could be used to ensure that this indeed happens as expected. Due to the presence of `Weak::upgrade`, the `strong_count` becomes less useful, but it still seems worthwhile to mirror the API of `Rc`. TODO: * [X] Tracking issue - https://github.com/rust-lang/rust/issues/57977 Closes https://github.com/rust-lang/rust/issues/50158
2019-01-29Add tracking issue to unstable attributeJonas Schievink-2/+2
2019-01-29Make weak_count return an Option<usize>Jonas Schievink-12/+10
2019-01-29Implement a slightly racy `sync::Weak::weak_count`Jonas Schievink-5/+70
2019-01-29Implement Weak::{strong_count, weak_count}Jonas Schievink-0/+19
2019-01-28Introduce into_raw_non_null on Rc and ArcDale Wijnand-0/+21
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-23Rollup merge of #56939 - cramertj:pin-stabilization, r=alexcrichtonMazdak Farrokhzad-3/+5
Pin stabilization This implements the changes suggested in https://github.com/rust-lang/rust/issues/55766#issue-378417538 and stabilizes the `pin` feature. @alexcrichton also listed several "blockers" in that issue, but then in [this comment](https://github.com/rust-lang/rust/issues/55766#issuecomment-445074980) mentioned that they're more "TODO items": > In that vein I think it's fine for a stabilization PR to be posted at any time now with FCP lapsed for a week or so now. The final points about self/pin/pinned can be briefly discussed there (if even necessary, they could be left as the proposal above). Let's settle these last bits here and get this thing stabilized! :) r? @alexcrichton cc @withoutboats
2018-12-23Rollup merge of #56941 - euclio:deny-libstd-resolution-failures, ↵kennytm-1/+4
r=QuietMisdreavus deny intra-doc link resolution failures in libstd Fixes #56693. Until we land a fix for the underlying issue (#56922), we can at least fix the failures in libstd so they don't propagate to downstream crates.
2018-12-21Rename Box/Arc/Rc::pinned to ::pinTaylor Cramer-1/+3
2018-12-21Stabilize PinTaylor Cramer-2/+2
2018-12-20Stabilize `Rc`, `Arc` and `Pin` as method receiversMichael Hewson-1/+4
This lets you write methods using `self: Rc<Self>`, `self: Arc<Self>`, `self: Pin<&mut Self>`, `self: Pin<Box<Self>`, and other combinations involving `Pin` and another stdlib receiver type, without needing the `arbitrary_self_types`. Other user-created receiver types can be used, but they still require the feature flag to use. This is implemented by introducing a new trait, `Receiver`, which the method receiver's type must implement if the `arbitrary_self_types` feature is not enabled. To keep composed receiver types such as `&Arc<Self>` unstable, the receiver type is also required to implement `Deref<Target=Self>` when the feature flag is not enabled. This lets you use `self: Rc<Self>` and `self: Arc<Self>` in stable Rust, which was not allowed previously. It was agreed that they would be stabilized in #55786. `self: Pin<&Self>` and other pinned receiver types do not require the `arbitrary_self_types` feature, but they cannot be used on stable because `Pin` still requires the `pin` feature.
2018-12-17deny intra-doc link resolution failures in libstdAndy Russell-1/+4
2018-12-08Use private trait for Rc/Arc Eq specializationThomas Heck-17/+37
2018-12-08Short-circuit Rc/Arc equality checking on equal pointers where T: EqJo Liss-3/+23
Closes #42655
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-12-03Add sync::Weak::ptr_eqThomas de Zeeuw-0/+47
2018-11-21update various stdlib docsSteve Klabnik-3/+2
2018-11-08Fix Rc/Arc allocation layoutMurarth-2/+4
* Rounds allocation layout up to a multiple of alignment * Adds a convenience method `Layout::pad_to_align` to perform rounding
2018-11-05Auto merge of #54922 - murarth:rc-ub-fix, r=alexcrichtonbors-5/+7
Fix undefined behavior in Rc/Arc allocation Manually calculate allocation layout for `Rc`/`Arc` to avoid undefined behavior Closes #54908
2018-11-05Fix undefined behavior in Rc/Arc allocationMurarth-5/+7
Manually calculate allocation layout for `Rc`/`Arc` to avoid undefined behavior
2018-11-01Replace CoerceSized trait with DispatchFromDynMichael Hewson-5/+5
Rename `CoerceSized` to `DispatchFromDyn`, and reverse the direction so that, for example, you write ``` impl<T: Unsize<U>, U> DispatchFromDyn<*const U> for *const T {} ``` instead of ``` impl<T: Unsize<U>, U> DispatchFromDyn<*const T> for *const U {} ``` this way the trait is really just a subset of `CoerceUnsized`. The checks in object_safety.rs are updated for the new trait, and some documentation and method names in there are updated for the new trait name — e.g. `receiver_is_coercible` is now called `receiver_is_dispatchable`. Since the trait now works in the opposite direction, some code had to updated here for that too. I did not update the error messages for invalid `CoerceSized` (now `DispatchFromDyn`) implementations, except to find/replace `CoerceSized` with `DispatchFromDyn`. Will ask for suggestions in the PR thread.
2018-11-01Add CoerceSized impls throughout libstdMichael Hewson-1/+6
This will make receiver types like `Rc<Self>` and `Pin<&mut Self>` object-safe.
2018-10-31Bump nightly to 1.32.0Alex Crichton-1/+1
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-12`#[must_use]` for associated functions is supposed to actually workZack M. Davis-2/+2
In the comments of (closed, defunct) pull request #54884, Mazdak "Centril" Farrokhzad noted that must-use annotations didn't work on an associated function (what other communities might call a "static method"). Subsequent logging revealed that in this case we have a `Def::Method`, whereas the lint pass was only matching on `Def::Fn`. (One could argue that those def-names are thereby misleading—must-use for self-ful methods have always worked—but documenting or reworking that can be left to another day.)
2018-10-01Introduce language items for `Arc` and `Rc`.David Wood-0/+1
This commit introduces language items for `Arc` and `Rc` so that types can later be checked to be `Arc` or `Rc` in the NLL borrow checker. The `lang` attribute is currently limited to `stage1` as it requires a compiler built with knowledge of the expected language items.
2018-09-19Auto merge of #53877 - withoutboats:compositional-pin, r=aturonbors-0/+6
Update to a new pinning API. ~~Blocked on #53843 because of method resolution problems with new pin type.~~ @r? @cramertj cc @RalfJung @pythonesque anyone interested in #49150
2018-09-08Auto merge of #51885 - GuillaumeGomez:trait-impl-show-docs, ↵bors-5/+3
r=Mark-Simulacrum,QuietMisdreavus Trait impl show docs Fixes #51834. <img width="1440" alt="screen shot 2018-06-29 at 00 14 33" src="https://user-images.githubusercontent.com/3050060/42063323-6e6e8cc8-7b31-11e8-88ef-4dd2229df76c.png"> (You can see both commit changes in the screenshot 😄) r? @QuietMisdreavus
2018-09-07Rollup merge of #53874 - withoutboats:pin-ptr-impls, r=RalfJungkennytm-1/+4
Implement Unpin for Box, Rc, and Arc Per the discussion in #49150, these should implement `Unpin` even if what they point to does not.
2018-09-06Fix invalid urlsGuillaume Gomez-5/+3
2018-09-01Update to a new pinning API.Without Boats-0/+6
2018-09-01Implement Unpin for Box, Rc, and ArcWithout Boats-1/+4
2018-08-31Add clearer wording to Arc clone example codeOtto Rask-1/+1
2018-08-30Rephrase Arc documentation changes regarding clonesOtto Rask-4/+4
Make it clearer that `Arc::clone()` in fact creates a whole new Arc with the internal pointer pointing to the same location as the source Arc.
2018-08-29Make Arc cloning mechanics clearer in module docsOtto Rask-4/+5
Add some more wording to module documentation regarding how `Arc::clone()` works, as some users have assumed cloning Arc's to work via dereferencing to inner value as follows: use std::sync::Arc; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(1 == myarcref); Instead of the actual mechanic of referencing the existing Arc value: use std::sync::Arg; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(myarcref == &myarc); // not sure if assert could assert this in the real world
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-1/+1
2018-07-23typosRalf Jung-2/+2
2018-07-23Don't use NonNull::dangling as sentinel valueRalf Jung-4/+9
Instead, rely on alignment and use usize::MAX as sentinel.