about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2017-07-24Rollup merge of #43374 - stjepang:fix-sort-randomization-comment, r=alexcrichtonMark Simulacrum-15/+18
Clarify that sort_unstable is deterministic @frankmcsherry complained that the documentation said "it is randomized but deterministic", which is a contradictory statement. This PR uses a different and clearer wording.
2017-07-22Use checked NonZero constructor instead of explicit null check in btreeSimon Sapin-6/+4
2017-07-22Add conversions from references to NonZero pointers, Unique, and SharedSimon Sapin-3/+3
2017-07-22Add Box::into_uniqueSimon Sapin-21/+48
2017-07-22Rename {NonZero,Shared,Unique}::new to new_uncheckedSimon Sapin-25/+25
2017-07-21Auto merge of #43318 - jhjourdan:jh/fix_weak_cound_MAX, r=alexcrichtonbors-1/+23
Fix in weak_count in Arc in the case the weak count is locked. In the case the weak count was locked, the weak_count function could return usize::MAX. We need to test this condition manually.
2017-07-21Clarify that sort_unstable is deterministicStjepan Glavina-15/+18
2017-07-20Auto merge of #43270 - petrochenkov:fixstab, r=alexcrichtonbors-2/+2
Fix checking for missing stability annotations This was a regression from https://github.com/rust-lang/rust/pull/37676 causing "unmarked API" ICEs like https://github.com/rust-lang/rust/issues/43027. r? @alexcrichton
2017-07-20Add test test_weak_count_lockedJacques-Henri Jourdan-0/+19
2017-07-19Add Vec::drain_filterAlexis Beingessner-0/+281
2017-07-18Fix in weak_count in Arc.Jacques-Henri Jourdan-1/+4
In the case the weak count was locked, the weak_count function could return usize::MAX. We need to test this condition manually.
2017-07-18Fix erroneous reference to Arc instead of RcLynn-1/+1
2017-07-16Fix checking for missing stability annotationsVadim Petrochenkov-2/+2
Remove couple of unnecessary `#![feature(staged_api)]`.
2017-07-13Add precondition to `Layout` that the `align` fit in a u32.Felix S. Klock II-7/+15
This precondition takes the form of a behavorial change in `Layout::from_size_align` (so it returns `None` if the `align` is too large) and a new requirement for safe usage of `Layout::from_size_align_unchecked`. Fix #30170.
2017-07-10Correct some stability attributesOliver Middleton-2/+2
These show up in rustdoc so need to be correct.
2017-07-06Auto merge of #42727 - alexcrichton:allocators-new, r=eddybbors-301/+238
rustc: Implement the #[global_allocator] attribute This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/1974 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-07-05rustc: Implement the #[global_allocator] attributeAlex Crichton-301/+238
This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/197 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-07-05Auto merge of #43050 - stjepang:doc-vec-fix-parens, r=frewsxcvbors-1/+1
Minor fix in docs for Vec Added missing parentheses after `mem::size_of::<T>`.
2017-07-04Rollup merge of #43041 - andersk:dedup_by, r=alexcrichtonMark Simulacrum-4/+12
Document unintuitive argument order for Vec::dedup_by relation When trying to use `dedup_by` to merge some auxiliary information from removed elements into kept elements, I was surprised to observe that `vec.dedup_by(same_bucket)` calls `same_bucket(a, b)` where `b` appears before `a` in the vector, and discards `a` when true is returned. This argument order is probably a bug, but since it has already been stabilized, I guess we should document it as a feature and move on. (`Vec::dedup` also uses `==` with this unexpected argument order, but I figure that’s not important since `==` is expected to be symmetric with no side effects.)
2017-07-04Rollup merge of #42227 - ollie27:into_to_from, r=aturonMark Simulacrum-4/+4
Convert Intos to Froms. This is a resubmission of #42129 without `impl<T> From<Vec<T>> for Box<[T]>`.
2017-07-04Minor fix in docs for VecStjepan Glavina-1/+1
2017-07-04Auto merge of #43012 - scottmcm:delete-range-step-by, r=alexcrichtonbors-2/+1
Delete deprecated & unstable range-specific `step_by` Using the new one is annoying while this one exists, since the inherent method hides the one on iterator. Tracking issue: #27741 Replacement: #41439 Deprecation: #42310 for 1.19 Fixes #41477
2017-07-03Document unintuitive argument order for Vec::dedup_by relationAnders Kaseorg-4/+12
When trying to use dedup_by to merge some auxiliary information from removed elements into kept elements, I was surprised to observe that vec.dedup_by(same_bucket) calls same_bucket(a, b) where b appears before a in the vector, and discards a when true is returned. This argument order is probably a bug, but since it has already been stabilized, I guess we should document it as a feature and move on. (Vec::dedup also uses == with this unexpected argument order, but I figure that’s not important since == is expected to be symmetric with no side effects.) Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2017-07-02Auto merge of #43010 - stjepang:stabilize-sort-unstable, r=alexcrichtonbors-14/+15
Stabilize feature sort_unstable Closes #40585
2017-07-02Remove the remaining feature gatesStjepan Glavina-1/+0
2017-07-02Fix lint errorsStjepan Glavina-1/+0
2017-07-01Delete deprecated & unstable range-specific `step_by`Scott McMurray-2/+1
Replacement: 41439 Deprecation: 42310 for 1.19 Fixes 41477
2017-07-02Stabilize feature sort_unstableStjepan Glavina-12/+15
2017-07-01Auto merge of #42882 - stjepang:improve-sort-tests-and-benches, r=alexcrichtonbors-33/+76
Improve tests and benchmarks for slice::sort and slice::sort_unstable This PR just hardens the tests and improves benchmarks. More specifically: 1. Benchmarks don't generate vectors in `Bencher::iter` loops, but simply clone pregenerated vectors. 2. Benchmark `*_strings` doesn't allocate Strings in `Bencher::iter` loops, but merely clones a `Vec<&str>`. 3. Benchmarks use seeded `XorShiftRng` to be more consistent. 4. Additional tests for `slice::sort` are added, which test sorting on slices with several ascending/descending runs. The implementation identifies such runs so it's a good idea to test that scenario a bit. 5. More checks are added to `run-pass/vector-sort-panic-safe.rs`. Sort algorithms copy elements around a lot (merge sort uses an auxilliary buffer and pdqsort copies the pivot onto the stack before partitioning, then writes it back into the slice). If elements that are being sorted are internally mutable and comparison function mutates them, it is important to make sure that sort algorithms always use the latest "versions" of elements. New checks verify that this is true for both `slice::sort` and `slice::sort_unstable`. As a side note, all of those improvements were made as part of the parallel sorts PR in Rayon (nikomatsakis/rayon#379) and now I'm backporting them into libcore/libstd. r? @alexcrichton
2017-06-30Revert "Stabilize RangeArgument"Steven Fackler-12/+200
This reverts commit 143206d54d7558c2326212df99efc98110904fdb.
2017-06-29Rollup merge of #42901 - alexcrichton:alloc-one, r=sfacklerAriel Ben-Yehuda-1/+1
std: Fix implementation of `Alloc::alloc_one` This had an accidental `u8 as *mut T` where it was intended to have just a normal pointer-to-pointer cast. Closes #42827
2017-06-29Rollup merge of #42832 - rthomas:doc-fmt, r=steveklabnikAriel Ben-Yehuda-5/+3
Update docs for std::fmt::format #29355. This rewords and removes the `Arguments` section from the docs for fmt::format. r? @steveklabnik
2017-06-25std: Fix implementation of `Alloc::alloc_one`Alex Crichton-1/+1
This had an accidental `u8 as *mut T` where it was intended to have just a normal pointer-to-pointer cast. Closes #42827
2017-06-24Stabilize RangeArgumentSteven Fackler-200/+12
Move it and Bound to core::ops while we're at it. Closes #30877
2017-06-24Improve sort tests and benchmarksStjepan Glavina-33/+76
2017-06-24Auto merge of #42854 - razielgn:relaxed-debug-constraints-on-maps-iterators, ↵bors-4/+4
r=sfackler Relaxed Debug constraints on {HashMap,BTreeMap}::{Keys,Values}. I has hit by this yesterday too. 😄 And I've realised that Debug for BTreeMap::{Keys,Values} wasn't formatting just keys and values respectively, but the whole map. 🤔 Fixed #41924 r? @jonhoo
2017-06-23Rollup merge of #42825 - letheed:patch-1, r=alexcrichtonMark Simulacrum-1/+1
Fix ref as mutable ref in std::rc::Rc doc
2017-06-23Relax Debug constraints when debugging {HashMap,BTreeMap}::{Keys,Values}.Federico Ravasio-2/+2
Fixed #41924.
2017-06-23Correctly iterate on keys/values when debugging BTreeMap::{Keys,Values}.Federico Ravasio-2/+2
2017-06-23Removed as many "```ignore" as possible.kennytm-7/+25
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-22Update docs for std::fmt::format #29355.Ryan Thomas-5/+3
This rewords and removes the `Arguments` section from the docs for fmt::format. r? @steveklabnik
2017-06-22Fix ref as mutable ref in std::rc::Rc docLetheed-1/+1
2017-06-21Update version numbers for From implsOliver Middleton-1/+1
2017-06-21Convert Intos to Froms.Clar Charr-3/+3
2017-06-20Rollup merge of #42717 - ollie27:into_to_from2, r=sfacklerCorey Farwell-4/+6
Convert `Into<Box<[T]>> for Vec<T>` into `From<Vec<T>> for Box<[T]>` As the `collections` crate has been merged into `alloc` in #42648 this impl is now possible. This is the final part of #42129 missing from #42227.
2017-06-20Auto merge of #42313 - pnkfelix:allocator-integration, r=alexcrichtonbors-118/+1339
Allocator integration Lets start getting some feedback on `trait Alloc`. Here is: * the `trait Alloc` itself, * the `struct Layout` and `enum AllocErr` that its API relies on * a `struct HeapAlloc` that exposes the system allocator as an instance of `Alloc` * an integration of `Alloc` with `RawVec` * ~~an integration of `Alloc` with `Vec`~~ TODO * [x] split `fn realloc_in_place` into `grow` and `shrink` variants * [x] add `# Unsafety` and `# Errors` sections to documentation for all relevant methods * [x] remove `Vec` integration with `Allocator` * [x] add `allocate_zeroed` impl to `HeapAllocator` * [x] remove typedefs e.g. `type Size = usize;` * [x] impl `trait Error` for all error types in PR * [x] make `Layout::from_size_align` public * [x] clarify docs of `fn padding_needed_for`. * [x] revise `Layout` constructors to ensure that [size+align combination is valid](https://github.com/rust-lang/rust/pull/42313#issuecomment-306845446) * [x] resolve mismatch re requirements of align on dealloc. See [comment](https://github.com/rust-lang/rust/pull/42313#issuecomment-306202489).
2017-06-19Minor Allocator doc fixAlex Crichton-1/+0
2017-06-17Convert `Into<Box<[T]>> for Vec<T>` into `From<Vec<T>> for Box<[T]>`Oliver Middleton-4/+6
2017-06-16Rollup merge of #42705 - est31:master, r=alexcrichtonCorey Farwell-2/+2
Introduce tidy lint to check for inconsistent tracking issues This PR * Refactors the collect_lib_features function to work in a non-checking mode (no bad pointer needed, and list of lang features). * Introduces checking whether unstable/stable tags for a given feature have inconsistent tracking issues, as in, multiple tracking issues per feature. * Fixes such inconsistencies throughout the codebase.
2017-06-16Introduce tidy lint to check for inconsistent tracking issuesest31-2/+2
This commit * Refactors the collect_lib_features function to work in a non-checking mode (no bad pointer needed, and list of lang features). * Introduces checking whether unstable/stable tags for a given feature have inconsistent tracking issues. * Fixes such inconsistencies throughout the codebase.