about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2019-02-02liballoc: cargo check passes on 2018Mazdak Farrokhzad-60/+61
2019-02-02liballoc => edition = 2018.Mazdak Farrokhzad-0/+1
2019-02-01Stabilize split_ascii_whitespaceSimon Sapin-2/+1
Tracking issue FCP to merge: https://github.com/rust-lang/rust/issues/48656#issuecomment-442372750
2019-01-31Auto merge of #56696 - jonas-schievink:weak-counts, r=alexcrichtonbors-1/+142
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-31Rollup merge of #57934 - dwijnand:from-Arc/Rc-to-NonNull, r=alexcrichtonMazdak Farrokhzad-0/+42
Introduce into_raw_non_null on Rc and Arc None
2019-01-30override `VecDeque`'s `Iter::try_fold`Andre Bogus-1/+47
2019-01-29Add tracking issue to unstable attributeJonas Schievink-4/+4
2019-01-29Make weak_count return an Option<usize>Jonas Schievink-26/+22
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/+80
2019-01-28Introduce into_raw_non_null on Rc and ArcDale Wijnand-0/+42
2019-01-28Rollup merge of #57045 - RalfJung:kill-more-uninit, r=SimonSapinMazdak Farrokhzad-21/+23
Kill remaining uses of mem::uninitialized in libcore, liballoc Kill remaining uses of mem::uninitialized in libcore and liballoc, and enable a lint that will warn when uses are added again in the future. To avoid casting raw pointers around (which is always very dangerous because it is not typechecked at all -- it doesn't even get the "same size" sanity check that `transmute` gets), I also added two new functions to `MaybeUninit`: ```rust /// Get a pointer to the first contained values. pub fn first_ptr(this: &[MaybeUninit<T>]) -> *const T { this as *const [MaybeUninit<T>] as *const T } /// Get a mutable pointer to the first contained values. pub fn first_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T { this as *mut [MaybeUninit<T>] as *mut T } ``` I changed some of the existing code to use array-of-`MaybeUninit` instead of `MaybeUninit`-of-array, successfully removing raw pointer casts there as well.
2019-01-28rename first_mut_ptr -> first_ptr_mutRalf Jung-5/+5
2019-01-28Use warn() for extra diagnostics; with -D warnings this leads to errorsRalf Jung-2/+2
This is needed to properly respect "deny_warnings = false" in config.toml
2019-01-28add macro for creating uninitialized arrayRalf Jung-9/+3
2019-01-28avoid some raw ptr casts in BTreeMapRalf Jung-7/+10
2019-01-28avoid mem::uninitialized in BTreeMapRalf Jung-9/+17
2019-01-28liballoc: remove unneeded allow(deprecated)Ralf Jung-3/+0
2019-01-27impl Generator for Pin<Box<Generator>>Wim Looman-0/+10
2019-01-27Change generator trait to use pinningWim Looman-7/+6
2019-01-26Replace deprecated ATOMIC_INIT constsMark Rousskov-4/+4
2019-01-26Bump bootstrap compiler to 1.33 betaMark Rousskov-1/+0
2019-01-15Deprecate the unstable Vec::resize_defaultScott McMurray-0/+4
2019-01-15Rollup merge of #57456 - fintelia:patch-4, r=dtolnayMazdak Farrokhzad-1/+1
RawVec doesn't always abort on allocation errors
2019-01-13Add a debug_assert to Vec::set_lenScott McMurray-0/+2
2019-01-12Rollup merge of #56425 - scottmcm:redo-vec-set_len-docs, r=CentrilMazdak Farrokhzad-27/+62
Redo the docs for Vec::set_len Inspired by the [recent conversation on IRLO](https://internals.rust-lang.org/t/make-vec-set-len-enforce-the-len-cap-invariant/8927/23?u=scottmcm). This is just my first stab at this; suggestions welcome.
2019-01-09explain safety for vec.set_len(0)Mazdak Farrokhzad-0/+3
2019-01-08RawVec doesn't always abort on allocation errorsJonathan Behrens-1/+1
2019-01-05Rollup merge of #57313 - Nemo157:box-to-pin, r=cramertjkennytm-5/+15
Improve Box<T> -> Pin<Box<T>> conversion I found the `From` trait conversion for this very hard to find, having a named function for it is much more discoverable. Also fixes #56256 as I need that in the place I'm using this. Has a placeholder tracking issue, will file an issue once I get feedback.
2019-01-03Add discoverable function for converting Box<T> -> Pin<Box<T>>Wim Looman-4/+14
2019-01-03Allow converting Box<T: !Sized> -> Pin<Box<T>>Wim Looman-1/+1
2019-01-02Update src/liballoc/vec.rs Mazdak Farrokhzad-0/+4
Add @centril's comment Co-Authored-By: scottmcm <scottmcm@users.noreply.github.com>
2018-12-29Mention ToString in std::fmt docsCzipperz-0/+9
2018-12-28Auto merge of #55519 - fhartwig:hashmap-index-example, r=Centrilbors-0/+3
Add example of using the indexing operator to HashMap docs Fixes #52575
2018-12-26Stabilize duration_as_u128Sunjay Varma-1/+1
2018-12-25Remove licensesMark Rousskov-511/+0
2018-12-24Rollup merge of #55470 - daniellimws:box-from-docs, r=CentrilMazdak Farrokhzad-0/+54
box: Add documentation for `From` impls This is a part of #51430. A brief description of the behaviour and examples are added to the documentation. I am not sure what sort of examples to put for the `From` for `Pin` as my [code](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=97c908f44e41c9faeffec5b61d72a03e) doesn't even manage to compile using the nightly build. Somehow I feel that I missed out something so do let me know if more information is needed in the documentation or any of the examples require change.
2018-12-23Rollup merge of #57032 - RalfJung:alloc-bench-deprecations, r=CentrilMazdak Farrokhzad-7/+10
fix deprecation warnings in liballoc benches
2018-12-23Rollup merge of #56939 - cramertj:pin-stabilization, r=alexcrichtonMazdak Farrokhzad-11/+16
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 #57002 - scottmcm:stabilize-resize_with, r=rkruppekennytm-6/+2
Stabilize Vec(Deque)::resize_with Closes #41758
2018-12-23Rollup merge of #56941 - euclio:deny-libstd-resolution-failures, ↵kennytm-2/+10
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-22Auto merge of #56842 - scottmcm:vecdeque-rotate, r=alexcrichtonbors-1/+248
Add unstable VecDeque::rotate_{left|right} Like the ones on slices, but more efficient because vecdeque is a circular buffer. Issue that proposed this: https://github.com/rust-lang/rust/issues/56686 ~~:bomb: Please someone look very carefully at the `unsafe` in this! The `wrap_copy` seems to be exactly what this method needs, and the `len` passed to it is never more than half the length of the deque, but I haven't managed to prove to myself that it's correct :bomb:~~ I think I proved that this code meets the requirement of the unsafe code it's calling; please double-check, of course.
2018-12-21Rename Box/Arc/Rc::pinned to ::pinTaylor Cramer-3/+9
2018-12-21Stabilize PinTaylor Cramer-8/+7
2018-12-21fix deprecation warnings in liballoc benchesRalf Jung-7/+10
2018-12-20Stabilize `Rc`, `Arc` and `Pin` as method receiversMichael Hewson-3/+15
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-19Stabilize Vec(Deque)::resize_withScott McMurray-6/+2
Closes #41758
2018-12-19Auto merge of #56550 - chpio:rc-eq, r=alexcrichtonbors-6/+168
Short-circuit Rc/Arc equality checking on equal pointers where T: Eq based on #42965 Is the use of the private trait ok this way? Is there anything else needed for this to get pulled?
2018-12-19Add more VecDeque::rotate_{left|right} testsScott McMurray-1/+136
2018-12-17deny intra-doc link resolution failures in libstdAndy Russell-2/+10