about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
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-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
2018-12-16Rollup merge of #56672 - ccouzens:master, r=nikicMazdak Farrokhzad-1/+5
Document time of back operations of a Linked List Popping and pushing from the end of a linked list is constant time. This documentation is already there for popping and pushing from the front. @bors: r+ 38fe8d2 rollup
2018-12-16Rollup merge of #56648 - RalfJung:btree, r=sfacklerMazdak Farrokhzad-57/+117
Fix BTreeMap UB BTreeMap currently causes UB by created a shared reference to a too-small allocation. This PR fixes that by introducing a `NodeHeader` type and using that until we really need access to the key/value arrays. Avoiding run-time checks in `into_key_slice` was somewhat tricky, see the comments embedded in the code. I also adjusted `as_leaf_mut` to return a raw pointer, because creating a mutable reference asserts that there are no aliases to the pointee, but that's not always correct: We use `as_leaf_mut` twice to create two mutable slices for keys and values; the second call overlaps with the first slice and hence is not a unique pointer. Fixes https://github.com/rust-lang/rust/issues/54957 Cc @nikomatsakis @Gankro
2018-12-15Add a note about why the unsafe is soundScott McMurray-0/+10
2018-12-15Rollup merge of #56713 - xfix:vec-test-zst-capacity, r=TimNNPietro Albini-0/+5
Test capacity of ZST vector Initially, #50233 accidentally changed the capacity of empty ZST. This was pointed out during code review. This commit adds a test to prevent capacity of ZST vectors from accidentally changing to prevent that from happening again.
2018-12-15Add unstable VecDeque::rotate_{left|right}Scott McMurray-0/+102
2018-12-14std: Activate compiler_builtins `mem` feature for no_std targetsAlex Crichton-0/+3
This was an accidental regression from #56092, but for `no_std` targets being built and distributed we want to be sure to activate the compiler-builtins `mem` feature which demangles important memory-related intrinsics.
2018-12-14Auto merge of #56536 - alexcrichton:update-master, r=Mark-Simulacrumbors-4/+4
Bump to 1.33.0 * Update bootstrap compiler * Update version to 1.33.0 * Remove some `#[cfg(stage0)]` annotations
2018-12-13Auto merge of #56161 - RalfJung:vecdeque-stacked-borrows, r=SimonSapinbors-1/+4
VecDeque: fix for stacked borrows `VecDeque` violates a version of stacked borrows where creating a shared reference is not enough to make a location *mutably accessible* from raw pointers (and I think that is the version we want). There are two problems: * Creating a `NonNull<T>` from `&mut T` goes through `&T` (inferred for a `_`), then `*const T`, then `NonNull<T>`. That means in this stricter version of Stacked Borrows, we cannot actually write to such a `NonNull` because it was created from a shared reference! This PR fixes that by going from `&mut T` to `*mut T` to `*const T`. * `VecDeque::drain` creates the `Drain` struct by *first* creating a `NonNull` from `self` (which is an `&mut VecDeque`), and *then* calling `self.buffer_as_mut_slice()`. The latter reborrows `self`, asserting that `self` is currently the unique pointer to access this `VecDeque`, and hence invalidating the `NonNull` that was created earlier. This PR fixes that by instead using `self.buffer_as_slice()`, which only performs read accesses and creates only shared references, meaning the raw pointer (`NonNull`) remains valid. It is possible that other methods on `VecDeque` do something similar, miri's test coverage of `VecDeque` is sparse to say the least. Cc @nikomatsakis @Gankro
2018-12-12Bump to 1.33.0Alex Crichton-4/+4
* Update bootstrap compiler * Update version to 1.33.0 * Remove some `#[cfg(stage0)]` annotations Actually updating the version number is blocked on updating Cargo
2018-12-11Update the comment some more following CR feedbackScott McMurray-9/+11
2018-12-11std: Depend directly on crates.io cratesAlex Crichton-6/+6
Ever since we added a Cargo-based build system for the compiler the standard library has always been a little special, it's never been able to depend on crates.io crates for runtime dependencies. This has been a result of various limitations, namely that Cargo doesn't understand that crates from crates.io depend on libcore, so Cargo tries to build crates before libcore is finished. I had an idea this afternoon, however, which lifts the strategy from #52919 to directly depend on crates.io crates from the standard library. After all is said and done this removes a whopping three submodules that we need to manage! The basic idea here is that for any crate `std` depends on it adds an *optional* dependency on an empty crate on crates.io, in this case named `rustc-std-workspace-core`. This crate is overridden via `[patch]` in this repository to point to a local crate we write, and *that* has a `path` dependency on libcore. Note that all `no_std` crates also depend on `compiler_builtins`, but if we're not using submodules we can publish `compiler_builtins` to crates.io and all crates can depend on it anyway! The basic strategy then looks like: * The standard library (or some transitive dep) decides to depend on a crate `foo`. * The standard library adds ```toml [dependencies] foo = { version = "0.1", features = ['rustc-dep-of-std'] } ``` * The crate `foo` has an optional dependency on `rustc-std-workspace-core` * The crate `foo` has an optional dependency on `compiler_builtins` * The crate `foo` has a feature `rustc-dep-of-std` which activates these crates and any other necessary infrastructure in the crate. A sample commit for `dlmalloc` [turns out to be quite simple][commit]. After that all `no_std` crates should largely build "as is" and still be publishable on crates.io! Notably they should be able to continue to use stable Rust if necessary, since the `rename-dependency` feature of Cargo is soon stabilizing. As a proof of concept, this commit removes the `dlmalloc`, `libcompiler_builtins`, and `libc` submodules from this repository. Long thorns in our side these are now gone for good and we can directly depend on crates.io! It's hoped that in the long term we can bring in other crates as necessary, but for now this is largely intended to simply make it easier to manage these crates and remove submodules. This should be a transparent non-breaking change for all users, but one possible stickler is that this almost for sure breaks out-of-tree `std`-building tools like `xargo` and `cargo-xbuild`. I think it should be relatively easy to get them working, however, as all that's needed is an entry in the `[patch]` section used to build the standard library. Hopefully we can work with these tools to solve this problem! [commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-12-11Test capacity of ZST vectorKonrad Borowski-0/+5
Initially, #50233 accidentally changed the capacity of empty ZST. This was pointed out during code review. This commit adds a test to prevent capacity of ZST vectors from accidentally changing to prevent that from happening again.
2018-12-11TypoAlexis Beingessner-1/+1
Co-Authored-By: RalfJung <post@ralfj.de>
2018-12-10Rollup merge of #56656 - BeatButton:liballoc_string_typo, r=CentrilGuillaume Gomez-1/+1
Fix typo
2018-12-10Document time of back operations of a Linked ListChris Couzens-1/+5
Popping and pushing from the end of a linked list is constant time. This documentation is already there for popping and pushing from the front. @bors: r+ 38fe8d2 rollup
2018-12-09Auto merge of #56463 - ljedrz:slice_concat_join, r=nikicbors-3/+3
slice: tweak concat & join - use `sum` instead of `fold` (readability) - adjust the capacity for `join` - the number of separators is `n - 1`, not `n`; proof: ``` fn main() { let a = [[1, 2], [4, 5]]; let v = a.join(&3); assert_ne!(v.len(), v.capacity()); // len is 5, capacity is 6 } ```
2018-12-09Fix typoBeatButton-1/+1
2018-12-09avoid as_leaf_mut asserting exclusive accessRalf Jung-30/+33
2018-12-09fix BTree creating shared references that are not entirely in-boundsRalf Jung-29/+86
2018-12-08Add Arc/Rc Eq testsThomas Heck-0/+84
2018-12-08Use private trait for Rc/Arc Eq specializationThomas Heck-37/+74
2018-12-08Short-circuit Rc/Arc equality checking on equal pointers where T: EqJo Liss-5/+46
Closes #42655
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-22/+22
2018-12-07Fix broken doc testCorey Farwell-1/+1
2018-12-07Drain only needs a shared referenceRalf Jung-7/+5
2018-12-07VecDeque::drain: make sure the 'drain' raw pointer is actually still usableRalf Jung-2/+7