about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2018-07-22Simplify vecdeque append testPazzaz-42/+64
2018-07-22Rollup merge of #51807 - newpavlov:deprecate_str_slice, r=alexcrichtonkennytm-9/+9
Deprecation of str::slice_unchecked(_mut) Closes #51715 I am not sure if 1.28.0 or 1.29.0 should be used for deprecation version, for now it's 1.28.0. Additionally I've replaced `slice_unchecked` uses with `get_unchecked`. The only places where this method is still used are `src/liballoc/tests/str.rs` and `src/liballoc/tests/str.rs`.
2018-07-20data_structures: Add a reference wrapper for pointer-indexed maps/setsVadim Petrochenkov-1/+1
Use `ptr::eq` for comparing pointers
2018-07-19Non-naive implementation for `VecDeque.append`Pazzaz-2/+192
2018-07-18Rollup merge of #52116 - Pazzaz:match-str-case, r=SimonSapinkennytm-2/+27
Handle array manually in str case conversion methods Avoiding the overhead incurred from `String.extend(char.to_lowercase())` showed a notable performance improvement when I benchmarked it. I tested on these strings: ```rust ALL_LOWER: "loremipsumdolorsitametduosensibusmnesarchumabcdefgh" ALL_UPPER: "LOREMIPSUMDOLORSITAMETDUOSENSIBUSMNESARCHUMABCDEFGH" REALISTIC_UPPER: "LOREM IPSUM DOLOR SIT AMET, DUO SENSIBUS MNESARCHUM" SIGMAS: "ΣΣΣΣΣ ΣΣΣΣΣ ΣΣΣΣΣ ΣΣΣ ΣΣΣΣ, ΣΣΣ ΣΣΣΣΣΣΣΣ ΣΣΣΣΣΣΣΣΣΣ" WORD_UPPER: "Lorem Ipsum Dolor Sit Amet, Duo Sensibus Mnesarchum" ``` the performance improvements of `to_lowercase()` were ``` running 10 tests test tests::all_lower ... bench: 1,752 ns/iter (+/- 49) test tests::all_lower_new ... bench: 1,266 ns/iter (+/- 15) -28% test tests::all_upper ... bench: 1,832 ns/iter (+/- 39) test tests::all_upper_new ... bench: 1,337 ns/iter (+/- 18) -27% test tests::realistic_upper ... bench: 1,993 ns/iter (+/- 14) test tests::realistic_upper_new ... bench: 1,445 ns/iter (+/- 22) -27% test tests::sigmas ... bench: 1,342 ns/iter (+/- 39) test tests::sigmas_new ... bench: 1,226 ns/iter (+/- 16) -9% test tests::word_upper ... bench: 1,899 ns/iter (+/- 12) test tests::word_upper_new ... bench: 1,381 ns/iter (+/- 26) -27% ``` and of `to_uppercase()` ``` running 10 tests test tests::all_lower ... bench: 1,813 ns/iter (+/- 20) test tests::all_lower_new ... bench: 1,321 ns/iter (+/- 16) -27% test tests::all_upper ... bench: 1,629 ns/iter (+/- 22) test tests::all_upper_new ... bench: 1,241 ns/iter (+/- 9) -24% test tests::realistic_upper ... bench: 1,670 ns/iter (+/- 24) test tests::realistic_upper_new ... bench: 1,241 ns/iter (+/- 17) -26% test tests::sigmas ... bench: 2,053 ns/iter (+/- 20) test tests::sigmas_new ... bench: 1,753 ns/iter (+/- 23) -15% test tests::word_upper ... bench: 1,873 ns/iter (+/- 30) test tests::word_upper_new ... bench: 1,412 ns/iter (+/- 25) -25% ``` I gave up on the more advanced method from #52061 as it wasn't always a clear improvement and would help in even less cases if this PR was merged.
2018-07-11Revert borked changes in last commit.ljedrz-14/+15
2018-07-10Add missing dyn in liballocljedrz-37/+36
2018-07-10Deny bare trait objects in in src/liballocljedrz-12/+13
2018-07-09doc: Clarify the lifetime returned by `Box::leak`Josh Stone-1/+3
`Box::leak` mentions that it can return a `'static` reference, but it wasn't immediately clear to me why it doesn't always do so. This is because of the `T: 'a` constraint needed to form a valid reference, and in general we want to be more flexible than requiring `T: 'static`. This patch tries to clarify the relationship between `T` and `'a`.
2018-07-09Auto merge of #52159 - SimonSapin:alloc-prelude, r=alexcrichtonbors-1/+30
Add the `alloc::prelude` module It contains the re-exports that are in `std::prelude::v1` but not in `core::prelude::v1`. Calling it prelude is somewhat of a misnomer since (unlike those modules in `std` or `core`) its contents are never implicitly imported in modules. Rather it is intended to be used with an explicit glob import like `use alloc::prelude::*;`. However there is precedent for the same misnomer with `std::io::prelude`, for example. This new module is unstable with the same feature name as the `alloc` care. They are proposed for stabilization together in RFC https://github.com/rust-lang/rfcs/pull/2480.
2018-07-09Removed a single trailing space. Oops.Orson Peters-1/+1
2018-07-09Reimplemented Vec's swap_remove to not rely on pop.Orson Peters-4/+6
2018-07-09Performance improvement of Vec's swap_remove.Orson Peters-3/+7
2018-07-07Add the `alloc::prelude` moduleSimon Sapin-1/+30
It contains the re-exports that are in `std::prelude::v1` but not in `core::prelude::v1`. Calling it prelude is somewhat of a misnomer since (unlike those modules in `std` or `core`) its contents are never implicitly imported in modules. Rather it is intended to be used with an explicit glob import like `use alloc::prelude::*;`. However there is precedent for the same misnomer with `std::io::prelude`, for example. This new module is unstable with the same feature name as the `alloc` care. They are proposed for stabilization together in RFC https://github.com/rust-lang/rfcs/pull/2480
2018-07-06Rollup merge of #52103 - tmccombs:rc_downcast, r=Mark-SimulacrumMark Rousskov-4/+2
Stabilize rc_downcast Fixes #44608
2018-07-07Fix is_dangling import when Arc is #[cfg]’ed outSimon Sapin-7/+7
2018-07-07Add some unit tests for dangling Weak referencesSimon Sapin-0/+112
2018-07-07Rc: remove unused allocation from Weak::new()Simon Sapin-24/+37
Same as https://github.com/rust-lang/rust/pull/50357
2018-07-07Use an aligned dangling pointer in Weak::new, rather than address 1Simon Sapin-21/+29
2018-07-06Handle array manually in string case conversion methodsPazzaz-2/+27
2018-07-06Auto merge of #51953 - japaric:atomic-load-store, r=alexcrichtonbors-4/+16
enable Atomic*.{load,store} for ARMv6-M / MSP430 closes #45085 as proposed in https://github.com/rust-lang/rust/issues/45085#issuecomment-384825434 this commit adds an `atomic_cas` target option and extends the `#[cfg(target_has_atomic)]` attribute to enable a subset of the `Atomic*` API on architectures that don't support atomic CAS natively, like MSP430 and ARMv6-M. r? @alexcrichton
2018-07-06Stabilize rc_downcastThayne McCombs-4/+2
Fixes #44608
2018-07-05#[cfg(target_has_atomic_cas)] -> #[cfg(target_has_atomic = "cas")]Jorge Aparicio-9/+16
2018-07-05enable Atomic*.{load,store} for ARMv6-M / MSP430Jorge Aparicio-4/+9
closes #45085 this commit adds an `atomic_cas` target option and an unstable `#[cfg(target_has_atomic_cas)]` attribute to enable a subset of the `Atomic*` API on architectures that don't support atomic CAS natively, like MSP430 and ARMv6-M.
2018-07-03Strenghten synchronization in `Arc::is_unique`Ralf Jung-6/+7
Previously, `is_unique` would not synchronize at all with a `drop` that returned early because it was not the last reference, leading to a data race. Fixes #51780
2018-07-03Rollup merge of #51914 - ↵Pietro Albini-7/+10
nikomatsakis:nll-fix-issue-issue-btreemap-annotations, r=gankro add outlives annotations to `BTreeMap` NLL requires these annotations, I believe because of <https://github.com/rust-lang/rust/issues/29149>. Fixes #48224 r? @Gankro cc @lqd
2018-07-02Implemented `UnsafeFutureObj` on `Box`Josef Reinhard Brandl-2/+21
2018-07-02Implement `UnsafeFutureObj` for `&mut Future`Josef Reinhard Brandl-1/+3
2018-07-02add outlives annotations to `BTreeMap`Niko Matsakis-7/+10
nll requires these annotations, I believe because of https://github.com/rust-lang/rust/issues/29149
2018-07-02`UnsafeFutureObj` impl for `PinMut`Josef Reinhard Brandl-7/+6
2018-07-02Add lifetime to `FutureObj`Josef Reinhard Brandl-8/+9
2018-07-02Use `From` impls for `FutureObj<()>`Josef Reinhard Brandl-12/+12
2018-07-02Make custom trait object for `Future` genericJosef Reinhard Brandl-15/+15
2018-07-02Make `BTreeMap::clone()` not allocate when cloning an empty tree.Nicholas Nethercote-1/+10
2018-06-30Auto merge of #51717 - Mark-Simulacrum:snap, r=alexcrichtonbors-1/+0
Bootstrap from 1.28.0 beta
2018-06-30Bootstrap from 1.28.0-beta.3Mark Simulacrum-1/+0
2018-06-29liballoc docs: Remove “not intended for general usage”Simon Sapin-4/+4
2018-06-29Rename alloc::arc to alloc::sync, to match std::syncSimon Sapin-3/+3
2018-06-29Remove the Vec and String reexports at the root of the alloc crateSimon Sapin-5/+0
… since `std` has no corresponding reexports. Use `alloc::vec::Vec` and `alloc::string::String` instead.
2018-06-29Move core::alloc::CollectionAllocErr to alloc::collectionsSimon Sapin-5/+34
2018-06-29Move some alloc crate top-level items to a new alloc::collections moduleSimon Sapin-42/+65
This matches std::collections
2018-06-29Remove the unstable alloc::allocator module reexport, deprecated since 1.27Simon Sapin-7/+0
2018-06-29Make raw_vec perma-unstable and hiddenSimon Sapin-2/+5
2018-06-28Arc: remove unused allocation from Weak::new()Sean McArthur-20/+36
2018-06-27Add str::split_ascii_whitespace.Clar Charr-0/+3
2018-06-26Add `LocalTaskObj`Josef Reinhard Brandl-2/+16
2018-06-26removed slice_uncheked from src/liballoc/tests/str.rsnewpavlov-4/+4
2018-06-26Deprecation of str::slice_uncheked(_mut)newpavlov-5/+5
2018-06-22Auto merge of #51463 - estebank:error-codes, r=nikomatsakisbors-2/+8
Various changes to existing diagnostics * [Add code to `invalid ABI` error, add span label, move list to help to make message shorter](https://github.com/rust-lang/rust/pull/51463/commits/23ae5af274defa9ff884f593e44a2bbcaf814a02): ``` error[E0697]: invalid ABI: found `路濫狼á́́` --> $DIR/unicode.rs:11:8 | LL | extern "路濫狼á́́" fn foo() {} //~ ERROR invalid ABI | ^^^^^^^^^ invalid ABI | = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted ``` * [Add code to incorrect `pub` restriction error](https://github.com/rust-lang/rust/pull/51463/commits/e96fdea8a38f39f99f8b9a4000a689187a457e08) * [Add message to `rustc_on_unimplemented` attributes in core to have them set a custom message _and_ label](https://github.com/rust-lang/rust/pull/51463/commits/2cc7e5ed307aee936c20479cfdc7409d6b52a464): ``` error[E0277]: `W` does not have a constant size known at compile-time --> $DIR/unsized-enum2.rs:33:8 | LL | VA(W), | ^ `W` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `W` = help: consider adding a `where W: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type ``` ``` error[E0277]: `Foo` cannot be sent between threads safely --> $DIR/E0277-2.rs:26:5 | LL | is_send::<Foo>(); | ^^^^^^^^^^^^^^ `Foo` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `Foo` ``` ``` error[E0277]: can't compare `{integer}` with `std::string::String` --> $DIR/binops.rs:16:7 | LL | 5 < String::new(); | ^ no implementation for `{integer} < std::string::String` and `{integer} > std::string::String` | = help: the trait `std::cmp::PartialOrd<std::string::String>` is not implemented for `{integer}` ``` ``` error[E0277]: can't compare `{integer}` with `std::result::Result<{integer}, _>` --> $DIR/binops.rs:17:7 | LL | 6 == Ok(1); | ^^ no implementation for `{integer} == std::result::Result<{integer}, _>` | = help: the trait `std::cmp::PartialEq<std::result::Result<{integer}, _>>` is not implemented for `{integer}` ``` ``` error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32` --> $DIR/type-check-defaults.rs:16:19 | LL | struct WellFormed<Z = Foo<i32, i32>>(Z); | ^ a collection of type `i32` cannot be built from `std::iter::Iterator<Item=i32>` | = help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32` note: required by `Foo` --> $DIR/type-check-defaults.rs:15:1 | LL | struct Foo<T, U: FromIterator<T>>(T, U); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` * [Add link to book for `Sized` errors](https://github.com/rust-lang/rust/pull/51463/commits/1244dc7c283323aea1a3457a4458d590a3e160c8): ``` error[E0277]: `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at compile-time --> $DIR/const-unsized.rs:13:29 | LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); | ^^^^^^^^^^^^^^^^^^^^^^ `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `std::fmt::Debug + std::marker::Sync + 'static` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized> = note: constant expressions must have a statically known size ``` * [Point to previous line for single expected token not found](https://github.com/rust-lang/rust/pull/51463/commits/48165168fb0f059d8536cd4a2276b609d4a7f721) (if the current token is in a different line)
2018-06-19Add message to `rustc_on_unimplemented` attributes in coreEsteban Küber-2/+8