about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2018-04-17Rollup merge of #50013 - frewsxcv:frewsxcv-ssplice, r=GuillaumeGomezGuillaume Gomez-3/+0
Remove no longer necessary comparison to Vec::splice. `String::replace_range` was previously called `String::splice`, so this note was necessary to differentiate it from the `Vec` method. Now that it's renamed, this note no longer seems necessary.
2018-04-17Remove no longer necessary comparison to Vec::splice.Corey Farwell-3/+0
`String::replace_range` was previously called `String::splice`, so this note was necessary to differentiate it from the `Vec` method. Now that it's renamed, this note no longer seems necessary.
2018-04-16Auto merge of #49488 - alexcrichton:small-wasm-panic, r=sfacklerbors-8/+15
std: Minimize size of panicking on wasm This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-17Rollup merge of #49555 - nox:inline-into-boxed, r=alexcrichtonkennytm-1/+9
Inline most of the code paths for conversions with boxed slices This helps with the specific problem described in #49541, obviously without making any large change to how inlining works in the general case. Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with `#[inline]`. For the record, that function was: ```rust pub fn foo() -> Box<[u8]> { vec![0].into_boxed_slice() } ``` To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
2018-04-16Auto merge of #48945 - clarcharr:iter_exhaust, r=Kimundibors-10/+6
Replace manual iterator exhaust with for_each(drop) This originally added a dedicated method, `Iterator::exhaust`, and has since been replaced with `for_each(drop)`, which is more idiomatic. <del>This is just shorthand for `for _ in &mut self {}` or `while let Some(_) = self.next() {}`. This states the intent a lot more clearly than the identical code: run the iterator to completion. <del>At least personally, my eyes tend to gloss over `for _ in &mut self {}` without fully paying attention to what it does; having a `Drop` implementation akin to: <del>`for _ in &mut self {}; unsafe { free(self.ptr); }`</del> <del>Is not as clear as: <del>`self.exhaust(); unsafe { free(self.ptr); }` <del>Additionally, I've seen debate over whether `while let Some(_) = self.next() {}` or `for _ in &mut self {}` is more clear, whereas `self.exhaust()` is clearer than both.
2018-04-15Remove #[inline(always)] on Vec::into_boxed_sliceAnthony Ramine-1/+0
2018-04-14Cleanup liballoc use statementsMike Hommey-15/+15
Some modules were still using the deprecated `allocator` module, use the `alloc` module instead. Some modules were using `super` while it's not needed. Some modules were more or less ordering them, and other not, so the latter have been modified to match the others.
2018-04-13Reduce the size of panics in RawVecAlex Crichton-8/+15
Create one canonical location which panics with "capacity overflow" instead of having many. This reduces the size of a `panic!("{}", 1)` binary on wasm from 34k to 17k.
2018-04-12Rename alloc::Void to alloc::OpaqueSimon Sapin-43/+43
2018-04-12Remove conversions for allocated pointersSimon Sapin-3/+3
One was now unused, and `NonNull::new(…).ok_or(AllocErr)` feels short enough for the few cases that need the other conversion.
2018-04-12Use NonNull<Void> instead of *mut u8 in the Alloc traitMike Hommey-65/+70
Fixes #49608
2018-04-12impl GlobalAlloc for GlobalSimon Sapin-35/+50
2018-04-12Restore Global.oom() functionalitySimon Sapin-0/+17
… now that #[global_allocator] does not define a symbol for it
2018-04-12realloc with a new size only, not a full new layout.Simon Sapin-26/+21
Changing the alignment with realloc is not supported.
2018-04-12Return Result instead of Option in alloc::Layout constructorsSimon Sapin-2/+2
2018-04-12Remove the now-unit-struct AllocErr field inside CollectionAllocErrSimon Sapin-22/+22
2018-04-12Remove the now-unit-struct AllocErr parameter of oom()Simon Sapin-13/+13
2018-04-12Use the GlobalAlloc trait for #[global_allocator]Simon Sapin-148/+40
2018-04-12Make AllocErr a zero-size unit structSimon Sapin-17/+17
2018-04-12Separate alloc::heap::Alloc trait for stage0 #[global_allocator]Simon Sapin-5/+104
2018-04-12Actually deprecate the Heap typeSimon Sapin-37/+37
2018-04-12Rename the Heap type to GlobalSimon Sapin-9/+14
… since it is the entry point for what’s registered with `#[global_allocator]`
2018-04-12Actually deprecate heap modules.Simon Sapin-3/+9
2018-04-12Rename `heap` modules in the core, alloc, and std crates to `alloc`Simon Sapin-2/+6
2018-04-12Inline docs for the heap module’s reexportsSimon Sapin-0/+2
2018-04-12Auto merge of #49551 - scottmcm:deprecate-offset_to, r=KodrAusbors-4/+5
Deprecate offset_to; switch core&alloc to using offset_from instead Bonus: might make code than uses `.len()` on slice iterators faster cc https://github.com/rust-lang/rust/issues/41079
2018-04-12Auto merge of #49698 - SimonSapin:unicode-for-everyone, r=alexcrichtonbors-25/+36
Merge the std_unicode crate into the core crate [The standard library facade](https://github.com/rust-lang/rust/issues/27783) has historically contained a number of crates with different roles, but that number has decreased over time. `rand` and `libc` have moved to crates.io, and [`collections` was merged into `alloc`](https://github.com/rust-lang/rust/pull/42648). Today we have `core` that applies everywhere, `std` that expects a full operating system, and `alloc` in-between that only requires a memory allocator (which can be provided by users)… and `std_unicode`, which doesn’t really have a reason to be separate anymore. It contains functionality based on Unicode data tables that can be large, but as long as relevant functions are not called the tables should be removed from binaries by linkers. This deprecates the unstable `std_unicode` crate and moves all of its contents into `core`, replacing them with `pub use` reexports. The crate can be removed later. This also removes the `CharExt` trait (replaced with inherent methods in libcore) and `UnicodeStr` trait (merged into `StrExt`). There traits were both unstable and not intended to be used or named directly. A number of new items are newly-available in libcore and instantly stable there, but only if they were already stable in libstd. Fixes #49319.
2018-04-12Mark the rest of the `unicode` feature flag as perma-unstable.Simon Sapin-2/+1
2018-04-12Merge unstable Utf16Encoder into EncodeUtf16Simon Sapin-7/+23
2018-04-12Merge core::unicode::str into core::strSimon Sapin-9/+9
And the UnicodeStr trait into StrExt
2018-04-12Reexport from core::unicode::char in core::char rather than vice versaSimon Sapin-2/+2
2018-04-12Deprecate the std_unicode crateSimon Sapin-11/+7
2018-04-12Move Utf8Lossy decoder to libcoreSimon Sapin-1/+1
2018-04-11Rollup merge of #49525 - varkor:sort_by_cached_key-conversion, r=scottmcmkennytm-0/+1
Use sort_by_cached_key where appropriate A follow-up to https://github.com/rust-lang/rust/pull/48639, converting various slice sorting calls to `sort_by_cached_key` when the key functions are more expensive.
2018-04-09Add trivial early return for sort_by_cached_keyvarkor-0/+1
2018-04-08Move deny(warnings) into rustbuildMark Simulacrum-5/+0
This permits easier iteration without having to worry about warnings being denied. Fixes #49517
2018-04-08Remove inline on Vec::shrink_to_fit as asked by AlexAnthony Ramine-1/+0
2018-04-07Auto merge of #49661 - alexcrichton:bump-bootstrap, r=nikomatsakisbors-4/+1
Bump the bootstrap compiler to 1.26.0 beta Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-04-07Inject the `compiler_builtins` crate whenever the `core` crate is injectedOliver Schneider-0/+1
2018-04-05Rollup merge of #49621 - Nemo157:impl-unpin-for-pin, r=withoutboatsAlex Crichton-0/+3
2018-04-05impl Unpin for PinBoxWim Looman-0/+3
2018-04-05Bump the bootstrap compiler to 1.26.0 betaAlex Crichton-4/+1
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-04-05Auto merge of #49684 - kennytm:rollup, r=kennytmbors-26/+55
Rollup of 9 pull requests Successful merges: - #48658 (Add a generic CAS loop to std::sync::Atomic*) - #49253 (Take the original extra-filename passed to a crate into account when resolving it as a dependency) - #49345 (RFC 2008: Finishing Touches) - #49432 (Flush executables to disk after linkage) - #49496 (Add more vec![... ; n] optimizations) - #49563 (add a dist builder to build rust-std components for the THUMB targets) - #49654 (Host compiler documentation: Include private items) - #49667 (Add more features to rust_2018_preview) - #49674 (ci: Remove x86_64-gnu-incremental builder) Failed merges:
2018-04-05Rollup merge of #49496 - glandium:master, r=sfacklerkennytm-26/+55
Add more vec![... ; n] optimizations vec![0; n], via implementations of SpecFromElem, has an optimization that uses with_capacity_zeroed instead of with_capacity, which will use calloc instead of malloc, and avoid an extra memset. This PR adds the same optimization for ptr::null, ptr::null_mut, and None, when their in-memory representation is zeroes.
2018-04-05Auto merge of #48851 - petrochenkov:genparattr, r=nikomatsakisbors-1/+1
Stabilize attributes on generic parameters Closes https://github.com/rust-lang/rust/issues/48848
2018-04-05Stabilize attributes on generic parametersVadim Petrochenkov-1/+1
2018-04-04Replace manual iter exhaust with for_each(drop).Clar Charr-10/+6
2018-04-04Rollup merge of #49607 - cuviper:stable-iter-1.27, r=alexcrichtonkennytm-1/+0
Stabilize iterator methods in 1.27 - Closes #39480, feature `iter_rfind` - `DoubleEndedIterator::rfind` - Closes #44705, feature `iter_rfold` - `DoubleEndedIterator::rfold` - Closes #45594, feature `iterator_try_fold` - `Iterator::try_fold` - `Iterator::try_for_each` - `DoubleEndedIterator::try_rfold`
2018-04-04Rollup merge of #49577 - tmccombs:string-splice-stabilize, r=TimNNkennytm-21/+20
Stabilize String::replace_range Fixes #44643
2018-04-04Rollup merge of #49559 - djc:resize-with, r=TimNNkennytm-7/+57
Introduce Vec::resize_with method (see #41758) In #41758, the libs team decided they preferred `Vec::resize_with` over `Vec::resize_default()`. Here is an implementation to get this moving forward. I don't know what the removal process for `Vec::resize_default()` should be, so I've left it in place for now. Would be happy to follow up with its removal.