about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2020-10-10Improve vec leak wordingIvan Tham-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-10Alloc vec doc mention cannot undo leakIvan Tham-1/+2
2020-10-09liballoc: VecDeque: Add binary search functionsVojtech Kral-1/+149
2020-10-09rename __default_lib_allocator -> __default_alloc_error_handlerRalf Jung-1/+1
2020-10-09also extend global allocator commentRalf Jung-2/+3
2020-10-09fix __rust_alloc_error_handler commentRalf Jung-2/+10
2020-10-08Rollup merge of #77449 - ssomers:btree_drain_filter_size_hint, r=Mark-SimulacrumJonas Schievink-0/+4
BTreeMap: comment why drain_filter's size_hint is somewhat pessimistic The `size_hint` of the `DrainFilter` iterator doesn't adjust as you iterate. This hardly seems important to me, but there has been a comparable PR #64383 in the past. I guess a scenario is that you first iterate half the map manually and keep most of the key/value pairs in the map, and then tell the predicate to drain most of the key/value pairs and `.collect` the iterator over the remaining half of the map. I am totally ambivalent whether this is better or not. r? @Mark-Simulacrum
2020-10-08Link Vec leak doc to BoxIvan Tham-1/+1
2020-10-08Rename LayoutErr to LayoutError outside of coreJacob Hughes-5/+5
2020-10-07Auto merge of #74194 - mbrubeck:slice-eq, r=sfacklerbors-0/+2
Add PartialEq impls for Vec <-> slice This is a follow-up to #71660 and rust-lang/rfcs#2917 to add two more missing vec/slice PartialEq impls: ``` impl<A, B> PartialEq<[B]> for Vec<A> where A: PartialEq<B> { .. } impl<A, B> PartialEq<Vec<B>> for [A] where A: PartialEq<B> { .. } ``` Since this is insta-stable, it should go through the `@rust-lang/libs` FCP process. Note that I used version 1.47.0 for the `stable` attribute because I assume this will not merge before the 1.46.0 branch is cut next week.
2020-10-07Support custom allocators in `Box`Tim Diekmann-149/+430
Remove `Box::leak_with_alloc` Add leak-test for box with allocator Rename `AllocErr` to `AllocError` in leak-test Add `Box::alloc` and adjust examples to use the new API
2020-10-06avoid unnecessary intermediate reference and improve safety commentsRalf Jung-6/+11
2020-10-05BTreeMap: derive type-specific variants of node_as_mut and cast_uncheckedStein Somers-24/+28
2020-10-05make IterMut Send/Sync againRalf Jung-0/+7
2020-10-05VecDeque: avoid more aliasing issues by working with raw pointers instead of ↵Ralf Jung-12/+31
references
2020-10-05VecDeque: fix incorrect &mut aliasing in IterMut::next/next_backRalf Jung-7/+24
2020-10-05Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebankDylan DPC-2/+4
Replace some once(x).chain(once(y)) with [x, y] IntoIter Now that we have by-value array iterators that are [already used](https://github.com/rust-lang/rust/blob/25c8c53dd994acb3f4f7c02fe6bb46076393f8b0/compiler/rustc_hir/src/def.rs#L305-L307)... For example, ```diff - once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it) + IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it) ```
2020-10-05Rollup merge of #77471 - ssomers:btree_cleanup_3, r=Mark-SimulacrumDylan DPC-7/+7
BTreeMap: refactoring around edges, missed spots Tweaks from #77244 (and more) that are really inconsistencies in #77005. r? @Mark-Simulacrum
2020-10-05Rollup merge of #77395 - ssomers:btree_love_the_leaf_edge_comments, ↵Dylan DPC-22/+12
r=Mark-Simulacrum BTreeMap: admit the existence of leaf edges in comments The btree code is ambiguous about leaf edges (i.e., edges within leaf nodes). Iteration relies on them heavily, but some of the comments suggest there are no leaf edges (extracted from #77025) r? @Mark-Simulacrum
2020-10-04Rollup merge of #77445 - ssomers:btree_cleanup_7, r=Mark-SimulacrumJonas Schievink-27/+118
BTreeMap: complete the compile-time test_variance test case Some of the items added to the new `test_sync` belonged in the old `test_variance` as well. And fixed inconsistent paths to nearby modules. r? @Mark-Simulacrum
2020-10-04Auto merge of #76448 - haraldh:default_alloc_error_handler_reduced, r=Amanieubors-0/+47
Implement Make `handle_alloc_error` default to panic (for no_std + liballoc) Related: https://github.com/rust-lang/rust/issues/66741 Guarded with `#![feature(default_alloc_error_handler)]` a default `alloc_error_handler` is called, if a custom allocator is used and no other custom `#[alloc_error_handler]` is defined.
2020-10-04Rollup merge of #77447 - ssomers:btree_cleanup_8, r=Mark-SimulacrumYuki Okushi-2/+6
BTreeMap: document DrainFilterInner better r? @Mark-Simulacrum
2020-10-03Replace some once(x).chain(once(y)) with [x, y] IntoIterScott McMurray-2/+4
Now that we have by-value array iterators...
2020-10-04BTreeMap/Set: complete the compile-time test casesStein Somers-27/+118
2020-10-03BTreeMap: comment why drain_filter's size_hint is somewhat pessimistictidStein Somers-0/+4
2020-10-03Auto merge of #74160 - CAD97:weak-as-unsized-ptr, r=RalfJungbors-44/+130
Allow Weak::as_ptr and friends for unsized T Relaxes `impl<T> Weak<T>` to `impl<T: ?Sized> Weak<T>` for the methods `rc::Weak::as_ptr`, `into_raw`, and `from_raw`. Follow-up to #73845, which did most of the impl work to make these functions work for `T: ?Sized`. We still have to adjust the implementation of `Weak::from_raw` here, however, because I missed a use of `ptr.is_null()` previously. This check was necessary when `into`/`from_raw` were first implemented, as `into_raw` returned `ptr::null()` for dangling weak. However, we now just (wrapping) offset dangling weaks' pointers the same as nondangling weak, so the null check is no longer necessary (or even hit). (I can submit just 17a928f as a separate PR if desired.) As a nice side effect, moves the `fn is_dangling` definition closer to `Weak::new`, which creates the dangling weak. This technically stabilizes that "something like `align_of_val_raw`" is possible to do. However, I believe the part of the functionality required by these methods here -- specifically, getting the alignment of a pointee from a pointer where it may be dangling iff the pointee is `Sized` -- is uncontroversial enough to stabilize these methods without a way to implement them on stable Rust. r? `@RalfJung,` who reviewed #73845. ATTN: This changes (relaxes) the (input) generic bounds on stable fn!
2020-10-03grammar nitRalf Jung-2/+2
2020-10-03BTreeMap: refactoring around edges, missed spotsStein Somers-7/+7
2020-10-03Rollup merge of #75377 - canova:map_debug_impl, r=dtolnayJonas Schievink-7/+51
Fix Debug implementations of some of the HashMap and BTreeMap iterator types HashMap's `ValuesMut`, BTreeMaps `ValuesMut`, IntoValues and `IntoKeys` structs were printing both keys and values on their Debug implementations. But they are iterators over either keys or values. Irrelevant values should not be visible. With this PR, they only show relevant fields. This fixes #75297. [Here's an example code.](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0c79356ed860e347a0c1a205616f93b7) This prints this on nightly: ``` ValuesMut { inner: IterMut { range: [(1, "hello"), (2, "goodbye")], length: 2 } } IntoKeys { inner: [(1, "hello"), (2, "goodbye")] } IntoValues { inner: [(1, "hello"), (2, "goodbye")] } [(2, "goodbye"), (1, "hello")] ``` After the patch this example prints these instead: ``` ["hello", "goodbye"] ["hello", "goodbye"] [1, 2] ["hello", "goodbye"] ``` I didn't add test cases for them, since I couldn't see any tests for Debug implementations anywhere. But please let me know if I should add it to a specific place. r? @dtolnay
2020-10-02BTreeMap: document DrainFilterInner betterStein Somers-2/+6
2020-10-02Implement Make `handle_alloc_error` default to panic (for no_std + liballoc)Harald Hoyer-0/+47
Related: https://github.com/rust-lang/rust/issues/66741 Guarded with `#![feature(default_alloc_error_handler)]` a default `alloc_error_handler` is called, if a custom allocator is used and no other custom `#[alloc_error_handler]` is defined. The panic message does not contain the size anymore, because it would pull in the fmt machinery, which would blow up the code size significantly.
2020-10-01BTreeMap: use Unique::from to avoid a cast where type information existsStein Somers-1/+1
2020-10-01BTreeMap: admit the existence of leaf edges in commentsStein Somers-22/+12
2020-10-01Auto merge of #77383 - pickfire:patch-6, r=Mark-Simulacrumbors-3/+4
Fix typo in vec doc "tries to reserves" Superseeds #77192
2020-10-01Fix typo in vec doc "tries to reserves"Ivan Tham-3/+4
2020-10-01Rollup merge of #77315 - exrook:rename-allocerror, r=joshtriplettDylan DPC-17/+17
Rename AllocErr to AllocError Implements rust-lang/wg-allocators#57
2020-09-30Rollup merge of #77340 - pickfire:patch-9, r=kennytmJonas Schievink-1/+1
Alloc vec use imported path mem::ManuallyDrop::new -> ManuallyDrop::new cc @the8472
2020-09-30Rollup merge of #77338 - pickfire:patch-7, r=jyn514Jonas Schievink-1/+1
Fix typo in alloc vec comment cc @the8472
2020-09-30Rollup merge of #77233 - ssomers:btree_size_matters, r=Mark-SimulacrumJonas Schievink-0/+9
BTreeMap: keep an eye out on the size of the main components r? @Mark-Simulacrum
2020-09-29Alloc vec use imported pathIvan Tham-1/+1
mem::ManuallyDrop::new -> ManuallyDrop::new
2020-09-29Fix typo in alloc vec commentIvan Tham-1/+1
2020-09-28Rename AllocErr to AllocErrorJacob Hughes-17/+17
2020-09-27Use relative links instead of intra-doc linksJoshua Nelson-1/+1
Previously, `BTreeMap` tried to link to `crate::collections`, intending for the link to go to `std/collections/index.html`. But `BTreeMap` is defined in `alloc`, so after the fix in the previous commit, the links instead went to `alloc/collections/index.html`, which has almost no information. This changes it to link to `index.html`, which only works when viewing from `std::collections::BTreeMap`, the most common place to visit the docs. Fixing it to work from anywhere would require the docs for `std::collections` to be duplicated in `alloc::collections`, which in turn would require HashMap to be `alloc` for intra-doc links to work (https://github.com/rust-lang/rust/issues/74481).
2020-09-26BTreeMap: keep an eye out on the size of the main componentsStein Somers-0/+9
2020-09-25Auto merge of #77201 - matthewjasper:rename-get-unchecked, r=spastorinobors-3/+9
Rename Iterator::get_unchecked Closes #76479 r? `@pnkfelix`
2020-09-25Rename Iterator::get_uncheckedMatthew Jasper-1/+1
It's possible for method resolution to pick this method over a lower priority stable method, causing compilation errors. Since this method is permanently unstable, give it a name that is very unlikely to be used in user code.
2020-09-25Improve <vec::IntoIter>::get_unchecked` safety commentMatthew Jasper-2/+8
2020-09-25Rollup merge of #77189 - pickfire:patch-5, r=Mark-SimulacrumJonas Schievink-1/+0
Remove extra space from vec drawing
2020-09-25Rollup merge of #77005 - ssomers:btree_cleanup_3, r=Mark-SimulacrumJonas Schievink-110/+99
BtreeMap: refactoring around edges Parts chipped off a more daring effort, that the btree benchmarks judge to be performance-neutral. r? @Mark-Simulacrum
2020-09-25Remove extra space from vec drawingIvan Tham-1/+0