about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2018-04-21Make the unstable StrExt and SliceExt traits private to libcore in not(stage0)Simon Sapin-1/+1
`Float` still needs to be public for libcore unit tests.
2018-04-21Add some f32 and f64 inherent methods in libcoreSimon Sapin-0/+1
… previously in the unstable core::num::Float trait. Per https://github.com/rust-lang/rust/issues/32110#issuecomment-379503183, the `abs`, `signum`, and `powi` methods are *not* included for now since they rely on LLVM intrinsics and we haven’t determined yet whether those instrinsics lower to calls to libm functions on any platform.
2018-04-21Replace StrExt with inherent str methods in libcoreSimon Sapin-1724/+8
2018-04-21Replace SliceExt with inherent [T] methods in libcoreSimon Sapin-1391/+6
2018-04-21Move non-allocating [u8] inherent methods to libcoreSimon Sapin-54/+4
Fixes #45803
2018-04-20Auto merge of #50088 - alexcrichton:std-tweaks, r=sfacklerbors-44/+2
Tweak some stabilizations in libstd This commit tweaks a few stable APIs in the `beta` branch before they hit stable. The `str::is_whitespace` and `str::is_alphanumeric` functions were deleted (added in #49381, issue at #49657). The `and_modify` APIs added in #44734 were altered to take a `FnOnce` closure rather than a `FnMut` closure. Closes #49581 Closes #49657
2018-04-19Tweak some stabilizations in libstdAlex Crichton-44/+2
This commit tweaks a few stable APIs in the `beta` branch before they hit stable. The `str::is_whitespace` and `str::is_alphanumeric` functions were deleted (added in #49381, issue at #49657). The `and_modify` APIs added in #44734 were altered to take a `FnOnce` closure rather than a `FnMut` closure. Closes #49581 Closes #49657
2018-04-18fix my unit test that was horrendously wrongMichael Lamparski-3/+17
and add one for non-mut slicing since I touched that method too
2018-04-18Auto merge of #50017 - tinaun:stabilize-all-the-things, r=sfacklerbors-18/+5
stabilize a bunch of minor api additions besides `ptr::NonNull::cast` (which is 4 days away from end of FCP) all of these have been finished with FCP for a few weeks now with minimal issues raised * Closes #41020 * Closes #42818 * Closes #44030 * Closes #44400 * Closes #46507 * Closes #47653 * Closes #46344 the following functions will be stabilized in 1.27: * `[T]::rsplit` * `[T]::rsplit_mut` * `[T]::swap_with_slice` * `ptr::swap_nonoverlapping` * `NonNull::cast` * `Duration::from_micros` * `Duration::from_nanos` * `Duration::subsec_millis` * `Duration::subsec_micros` * `HashMap::remove_entry`
2018-04-17smaller PR just to fix #50002Michael Lamparski-0/+16
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-17stabilize `nonnull_cast` featuretinaun-1/+0
2018-04-17stabilize `swap_with_slice` featuretinaun-8/+2
2018-04-17stabilize `slice_rsplit` featuretinaun-9/+3
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-11alloc: Mark `Box::into_unique` with `#[doc(hidden)]`Daiki Mizukami-0/+1
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