about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2019-05-22Rollup merge of #60963 - blkerby:boxed_docs, r=alexcrichtonMazdak Farrokhzad-25/+64
Update boxed::Box docs on memory layout The existing docs for the `Box` type state that "the way `Box` allocates and releases memory is unspecified", and that therefore the only valid pointer to pass to `Box::from_raw` is one obtained from `Box::into_raw`. This is inconsistent with the module-level docs which specify, > It is valid to convert both ways between a Box and a raw pointer allocated with the Global allocator, given that the Layout used with the allocator is correct for the type. More precisely, a value: *mut T that has been allocated with the Global allocator with Layout::for_value(&*value) may be converted into a box using Box::<T>::from_raw(value). Conversely, the memory backing a value: *mut T obtained from Box::<T>::into_raw may be deallocated using the Global allocator with Layout::for_value(&*value). This pull request updates the docs for `Box` to make them consistent with the module-level docs and adds some examples of how to use the global allocator in conjunction with `Box::from_raw` and `Box::into_raw`.
2019-05-20Create and reference Memory Layout section of boxed docsBrent Kerby-31/+39
2019-05-20Rollup merge of #60952 - dtolnay:heap, r=AmanieuMazdak Farrokhzad-0/+43
Document BinaryHeap time complexity I went into some detail on the time complexity of `push` because it is relevant for using BinaryHeap efficiently -- specifically that you should avoid pushing many elements in ascending order when possible. r? @Amanieu Closes #47976. Closes #59698.
2019-05-20Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPCMazdak Farrokhzad-0/+18
Fix intra-doc link resolution failure on re-exporting libstd Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366). ```rust pub use std::*; ``` Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates. Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.) r? @QuietMisdreavus
2019-05-20Remove trailing whitespaces to satisfy tidyBrent Kerby-5/+5
2019-05-20Update boxed::Box docs on memory layoutBrent Kerby-14/+45
2019-05-20stabilize core parts of MaybeUninit and deprecate mem::uninitialized in the ↵Ralf Jung-1/+1
future Also expand the documentation a bit
2019-05-18Document BinaryHeap time complexityDavid Tolnay-0/+43
I went into some detail on the time complexity of `push` because it is relevant for using BinaryHeap efficiently -- specifically that you should avoid pushing many elements in ascending order when possible.
2019-05-19Rollup merge of #60931 - cuviper:array-iter, r=KodrAusMazdak Farrokhzad-2/+2
Use iter() for iterating arrays by slice These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-19Rollup merge of #60678 - DutchGhost:master, r=scottmcmMazdak Farrokhzad-7/+2
Stabilize vecdeque_rotate This PR stabilizes the vecdeque_rotate feature. r? @scottmcm Closes https://github.com/rust-lang/rust/issues/56686
2019-05-17Use iter() for iterating arrays by sliceJosh Stone-2/+2
These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-17Update the compiler_builtins crateAlex Crichton-0/+1
This updates to 0.1.13 for `compiler_builtins`, published to fix a few issues. The feature changes here are updated because `compiler_builtins` no longer enables the `c` feature by default but we want to do so through our build still. Closes #60747 Closes #60782
2019-05-16Rollup merge of #59825 - jsgf:from-ref-string, r=sfacklerMazdak Farrokhzad-0/+8
string: implement From<&String> for String Allow Strings to be created from borrowed Strings. This is mostly to make things like passing `&String` to an `impl Into<String>` parameter frictionless. Fixes #59827.
2019-05-14Rollup merge of #60130 - khuey:efficient_last, r=sfacklerMazdak Farrokhzad-0/+88
Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators Provided a `DoubleEndedIterator` has finite length, `Iterator::last` is equivalent to `DoubleEndedIterator::next_back`. But searching forwards through the iterator when it's unnecessary is obviously not good for performance. I ran into this on one of the collection iterators. I tried adding appropriate overloads for a bunch of the iterator adapters like filter, map, etc, but I ran into a lot of type inference failures after doing so. The other interesting case is what to do with `Repeat`. Do we consider it part of the contract that `Iterator::last` will loop forever on it? The docs do say that the iterator will be evaluated until it returns None. This is also relevant for the adapters, it's trivially easy to observe whether a `Map` adapter invoked its closure a zillion times or just once for the last element.
2019-05-12Auto merge of #60396 - cuviper:ordered-retain, r=scottmcmbors-6/+40
Document the order of {Vec,VecDeque,String}::retain It's natural for `retain` to work in order from beginning to end, but this wasn't actually documented to be the case. If we actually promise this, then the caller can do useful things like track the index of each element being tested, as [discussed in the forum][1]. This is now documented for `Vec`, `VecDeque`, and `String`. [1]: https://users.rust-lang.org/t/vec-retain-by-index/27697 `HashMap` and `HashSet` also have `retain`, and the `hashbrown` implementation does happen to use a plain `iter()` order too, but it's not certain that this should always be the case for these types. r? @scottmcm
2019-05-11add comment to `Rc`/`Arc`'s `Eq` specializationThomas Heck-0/+10
2019-05-10Add examples of ordered retainJosh Stone-0/+34
2019-05-10Auto merge of #60451 - rasendubi:binaryheap-min-heap, r=scottmcmbors-0/+24
BinaryHeap: add min-heap example Fixes #58174.
2019-05-09supposed to be 1.36.0Dodo-2/+2
2019-05-09make vecdeque_rotate stableDodo-7/+2
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-0/+18
2019-05-04Remove unused feature(need_allocator).Mazdak Farrokhzad-1/+0
2019-05-01BinaryHeap: add min-heap exampleAlexey Shmalko-0/+24
2019-04-30Implement `BorrowMut<str>` for `String`YOSHIOKA Takuma-1/+9
Closes rust-lang/rfcs#1282.
2019-04-29Document the order of {Vec,VecDeque,String}::retainJosh Stone-6/+6
It's natural for `retain` to work in order from beginning to end, but this wasn't actually documented to be the case. If we actually promise this, then the caller can do useful things like track the index of each element being tested, as [discussed in the forum][1]. This is now documented for `Vec`, `VecDeque`, and `String`. [1]: https://users.rust-lang.org/t/vec-retain-by-index/27697 `HashMap` and `HashSet` also have `retain`, and the `hashbrown` implementation does happen to use a plain `iter()` order too, but it's not certain that this should always be the case for these types.
2019-04-26Use "capacity" as parameter name in with_capacity() methodsMatthias Geier-4/+4
Closes #60271.
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+2
2019-04-23Stabilize futures_apiTaylor Cramer-2/+1
2019-04-22Remove double trailing newlinesvarkor-1/+0
2019-04-20Deny rust_2018_idioms in liballoc testsPhilipp Hansch-14/+15
2019-04-19Add implementations of last in terms of next_back on a bunch of ↵Kyle Huey-0/+88
DoubleEndedIterators. r?Manishearth
2019-04-19Auto merge of #60072 - RalfJung:linked-list, r=shepmasterbors-11/+37
fix LinkedList invalidating mutable references The test `test_insert_prev` failed in Miri due to what I consider a bug in `LinkedList`: in various places, `NonNull::as_mut` got called to modify the `prev`/`next` pointers of existing nodes. In particular, the unstable `insert_next` has to modify the `next` pointer of the node that was last handed out by the iterator; to this end it creates a mutable reference to the *entire node* that overlaps with the mutable reference to the node's content that was handed out by the iterator! Thus, the next use if said mutable reference is UB. In code: ```rust loop { match it.next() { // mutable reference handed to us None => break, Some(elt) => { it.insert_next(*elt + 1); // this invalidates `elt` because it creates an overlapping mutable reference match it.peek_next() { Some(x) => assert_eq!(*x, *elt + 2), // this use of `elt` now is a use of an invalid pointer None => assert_eq!(8, *elt), } } } } ``` This PR fixes that by using `as_ptr` instead of `as_mut`. This avoids invalidating the mutable reference that was handed to the user. I did this in all methods called by iterators, just to be sure. Cc @Gankro
2019-04-19fix LinkedList invalidating mutable referencesRalf Jung-11/+37
2019-04-19Auto merge of #60077 - RalfJung:miri-alloc-tests, r=joshtriplettbors-1/+15
make liballoc internal test suite mostly pass in Miri I discovered, to my surprise, that liballoc has two test suites: `liballoc/tests`, and a bunch of stuff embedded directly within liballoc. The latter was not covered by [miri-test-libstd](https://github.com/RalfJung/miri-test-libstd) yet. This disables in Miri the tests that Miri cannot support or runs too slowly.
2019-04-19move variable down to where it is usedRalf Jung-5/+5
2019-04-19Rollup merge of #59933 - sourcefrog:doc-fmt, r=shepmasterMazdak Farrokhzad-3/+4
Make clear that format padding doesn't work for Debug As mentioned in https://github.com/rust-lang/rust/issues/46006#issuecomment-345260633
2019-04-18make liballoc internal test suite mostly pass in MiriRalf Jung-1/+15
2019-04-18Rollup merge of #59908 - lzutao:str_escape, r=SimonSapinMazdak Farrokhzad-0/+2
Re-export core::str::{EscapeDebug, EscapeDefault, EscapeUnicode} in std cc #59893
2019-04-17test sort_unstable in MiriRalf Jung-3/+3
2019-04-16Miri now supports entropy, but is still slowRalf Jung-7/+16
2019-04-15warn(missing_docs) in liballoc, and add missing docsRalf Jung-0/+13
2019-04-14make lint levels more consistentRalf Jung-3/+3
2019-04-14bump stdsimd; make intra_doc_link_resolution_failure an error againRalf Jung-1/+1
2019-04-14Rollup merge of #59675 - SimonSapin:stable-alloc, r=alexcrichtonMazdak Farrokhzad-7/+3
Stabilize the `alloc` crate. This implements RFC 2480: * https://github.com/rust-lang/rfcs/pull/2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes https://github.com/rust-lang/rust/issues/27783
2019-04-13Make clear that format padding doesn't work for DebugMartin Pool-3/+4
As mentioned in https://github.com/rust-lang/rust/issues/46006#issuecomment-345260633
2019-04-12Stabilize the `alloc` crate.Simon Sapin-7/+3
This implements RFC 2480: * https://github.com/rust-lang/rfcs/pull/2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes https://github.com/rust-lang/rust/issues/27783
2019-04-12Rollup merge of #59814 - ollie27:dead_boxed_links, r=QuietMisdreavusMazdak Farrokhzad-0/+2
Fix broken links on std::boxed doc page r? @QuietMisdreavus
2019-04-12Re-export core::str::{EscapeDebug, EscapeDefault, EscapeUnicode} in stdLzu Tao-0/+2
2019-04-11Fix broken links on std::boxed doc pageOliver Middleton-0/+2
2019-04-10Update cmake, cc and compiler_builtins for VS 2019 supportJohn Kåre Alsaker-1/+1