about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2020-12-11doc: apply suggestionsWilliam Woodruff-2/+3
2020-12-10Rollup merge of #79860 - rust-lang:frewsxcv-patch-2, r=jyn514Tyler Mandry-1/+1
Clarify that String::split_at takes a byte index. To someone skimming through the `String` docs and only reads the first line, the person could interpret "index" to be "char index". Later on in the docs it clarifies, but by adding "byte" it removes that ambiguity.
2020-12-10doc(array,vec): add notes about side effects when empty-initializingWilliam Woodruff-0/+3
2020-12-10Fix the fmt issuesClément Renault-2/+2
2020-12-10Auto merge of #79814 - lcnr:deque-f, r=Mark-Simulacrumbors-5/+27
fix soundness issue in `make_contiguous` fixes #79808
2020-12-10Use none as the issue instead of 0Clément Renault-1/+1
2020-12-10Introduce the GroupBy and GroupByMut IteratorsClément Renault-0/+3
2020-12-09Rollup merge of #79795 - matklad:unicode-private, r=cramertjTyler Mandry-1/+1
Privatize some of libcore unicode_internals My understanding is that these API are perma unstable, so it doesn't make sense to pollute docs & IDE completion[1] with them. [1]: https://github.com/rust-analyzer/rust-analyzer/issues/6738
2020-12-09Clarify that String::split_at takes a byte index.Corey Farwell-1/+1
2020-12-08Remove deprecated linked_list_extras methods.Mara Bos-62/+0
2020-12-08fix unsoundness in `make_contiguous`Bastian Kauschke-5/+27
2020-12-08Do not inline finish_growMike Hommey-1/+5
We also change the specialization of `SpecFromIterNested::from_iter` for `TrustedLen` to use `Vec::with_capacity` when the iterator has a proper size hint, instead of `Vec::new`, avoiding calls to `grow_*` and thus `finish_grow` in some fully inlinable cases, which would regress with this change. Fixes #78471.
2020-12-07Removed spurious linebreak from new documentationChai T. Rex-1/+1
2020-12-07Improved documentation for HashMap/BTreeMap Entry's .or_insert_with_key methodChai T. Rex-3/+6
2020-12-07Privatize some of libcore unicode_internalsAleksey Kladov-1/+1
My understanding is that these API are perma unstable, so it doesn't make sense to pollute docs & IDE completion[1] with them. [1]: https://github.com/rust-analyzer/rust-analyzer/issues/6738
2020-12-05Auto merge of #78373 - matthewjasper:drop-on-into, r=pnkfelixbors-1/+1
Don't leak return value after panic in drop Closes #47949
2020-12-04Avoid leaking block expression valuesMatthew Jasper-1/+1
2020-12-04 Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate`Tim Diekmann-250/+253
2020-12-01Update rustc version that or_insert_with_key landedChai T. Rex-1/+1
2020-11-29Rollup merge of #79363 - ssomers:btree_cleanup_comments, r=Mark-SimulacrumDylan DPC-89/+118
BTreeMap: try to enhance various comments All in internal documentation, propagating the "key-value pair" notation from public documentation. r? ``@Mark-Simulacrum``
2020-11-29Rollup merge of #79327 - TimDiekmann:static-alloc-pin-in-box, r=Mark-SimulacrumDylan DPC-7/+25
Require allocator to be static for boxed `Pin`-API Allocators has to retain their validity until the instance and all of its clones are dropped. When pinning a value, it must live forever, thus, the allocator requires a `'static` lifetime for pinning a value. [Example from reddit](https://www.reddit.com/r/rust/comments/jymzdw/the_story_continues_vec_now_supports_custom/gd7qak2?utm_source=share&utm_medium=web2x&context=3): ```rust let alloc = MyAlloc(/* ... */); let pinned = Box::pin_in(42, alloc); mem::forget(pinned); // Now `value` must live forever // Otherwise `Pin`'s invariants are violated, storage invalidated // before Drop was called. // borrow of `memory` can end here, there is no value keeping it. drop(alloc); // Oh, value doesn't live forever. ```
2020-11-28Require allocator to be static for boxed `Pin`-APITim Diekmann-7/+25
2020-11-28BTreeMap: try to enhance various comments & local identifiersStein Somers-89/+118
2020-11-25Auto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obkbors-1/+2
Rename `optin_builtin_traits` to `auto_traits` They were originally called "opt-in, built-in traits" (OIBITs), but people realized that the name was too confusing and a mouthful, and so they were renamed to just "auto traits". The feature flag's name wasn't updated, though, so that's what this PR does. There are some other spots in the compiler that still refer to OIBITs, but I don't think changing those now is worth it since they are internal and not particularly relevant to this PR. Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>. r? `@oli-obk` (feel free to re-assign if you're not the right reviewer for this)
2020-11-24Rollup merge of #79358 - ssomers:btree_public_comments, r=Mark-SimulacrumJonas Schievink-4/+6
BTreeMap/BTreeSet: make public doc more consistent Tweaks #72876 and #73667 and propagate them to `BTreeSet`.
2020-11-24Rollup merge of #79354 - ssomers:btree_bereave_BoxedNode, r=Mark-SimulacrumJonas Schievink-38/+12
BTreeMap: cut out the ceremony around BoxedNode The opposite direction of #79093. r? ``@Mark-Simulacrum``
2020-11-23Rename `optin_builtin_traits` to `auto_traits`Camelid-1/+2
They were originally called "opt-in, built-in traits" (OIBITs), but people realized that the name was too confusing and a mouthful, and so they were renamed to just "auto traits". The feature flag's name wasn't updated, though, so that's what this PR does. There are some other spots in the compiler that still refer to OIBITs, but I don't think changing those now is worth it since they are internal and not particularly relevant to this PR. Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
2020-11-23BTreeMap/BTreeSet: make public doc more consistentStein Somers-4/+6
2020-11-23Auto merge of #79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievinkbors-2/+2
Rollup of 10 pull requests Successful merges: - #76829 (stabilize const_int_pow) - #79080 (MIR visitor: Don't treat debuginfo field access as a use of the struct) - #79236 (const_generics: assert resolve hack causes an error) - #79287 (Allow using generic trait methods in `const fn`) - #79324 (Use Option::and_then instead of open-coding it) - #79325 (Reduce boilerplate with the `?` operator) - #79330 (Fix typo in comment) - #79333 (doc typo) - #79337 (Use Option::map instead of open coding it) - #79343 (Add my (`@flip1995)` work mail to the mailmap) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-11-23BTreeMap: cut out the ceremony around BoxedNodeStein Somers-38/+12
2020-11-23Rollup merge of #79333 - o752d:patch-3, r=Mark-SimulacrumJonas Schievink-2/+2
doc typo plus a small edit for clarity
2020-11-23Auto merge of #79186 - JulianKnodt:str_from, r=Mark-Simulacrumbors-17/+75
Change slice::to_vec to not use extend_from_slice I saw this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/String.3A.3Afrom%28.26str%29.20wonky.20codegen/near/216164455), and didn't see any update from it, so I thought I'd try to fix it. This converts `to_vec` to no longer use `extend_from_slice`, but relies on knowing that the allocated capacity is the same size as the input. [Godbolt new v1](https://rust.godbolt.org/z/1bcWKG) [Godbolt new v2 w/ drop guard](https://rust.godbolt.org/z/5jn76K) [Godbolt old version](https://rust.godbolt.org/z/e4ePav) After some amount of iteration, there are now two specializations for `to_vec`, one for `Copy` types that use memcpy, and one for clone types which is the original from this PR. This is then used inside of `impl<T: Clone> FromIterator<Iter::Slice<T>> for Vec<T>` which is essentially equivalent to `&[T] -> Vec<T>`, instead of previous specialization of the `extend` function. This is because extend has to reason more about existing capacity by calling `reserve` on an existing vec, and thus produces worse asm. Downsides: This allocates the exact capacity, so I think if many items are added to this `Vec` after, it might need to allocate whereas extending may not. I also noticed the number of faults went up in the benchmarks, but not sure where from exactly.
2020-11-23doc typooliver-2/+2
plus a small edit for clarity
2020-11-23Auto merge of #79172 - a1phyr:cold_abort, r=Mark-Simulacrumbors-0/+1
Add #[cold] attribute to `std::process::abort` and `alloc::alloc::handle_alloc_error`
2020-11-22Auto merge of #79319 - m-ou-se:rollup-d9n5viq, r=m-ou-sebors-65/+62
Rollup of 10 pull requests Successful merges: - #76941 (Add f{32,64}::is_subnormal) - #77697 (Split each iterator adapter and source into individual modules) - #78305 (Stabilize alloc::Layout const functions) - #78608 (Stabilize refcell_take) - #78793 (Clean up `StructuralEq` docs) - #79267 (BTreeMap: address namespace conflicts) - #79293 (Add test for eval order for a+=b) - #79295 (BTreeMap: fix minor testing mistakes in #78903) - #79297 (BTreeMap: swap the names of NodeRef::new and Root::new_leaf) - #79299 (Stabilise `then`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-11-22Change slice::to_vec to not use extend_from_slicekadmin-17/+75
This also required adding a loop guard in case clone panics Add specialization for copy There is a better version for copy, so I've added specialization for that function and hopefully that should speed it up even more. Switch FromIter<slice::Iter> to use `to_vec` Test different unrolling version for to_vec Revert to impl From benchmarking, it appears this version is faster
2020-11-22Rollup merge of #79297 - ssomers:btree_post_redux, r=Mark-SimulacrumMara Bos-14/+14
BTreeMap: swap the names of NodeRef::new and Root::new_leaf #78104 preserved the name of Root::new_leaf to minimize changes, but the resulting names are confusing. r? `@Mark-Simulacrum`
2020-11-22Rollup merge of #79295 - ssomers:btree_fix_78903, r=Mark-SimulacrumMara Bos-16/+15
BTreeMap: fix minor testing mistakes in #78903 Mostly a duplicate test case r? `@Mark-Simulacrum`
2020-11-22Rollup merge of #79267 - ssomers:btree_namespaces, r=Mark-SimulacrumMara Bos-35/+33
BTreeMap: address namespace conflicts Fix an annoyance popping up whenever synchronizing the test cases with a version capable of miri-track-raw-pointers. r? `@Mark-Simulacrum`
2020-11-22Auto merge of #79219 - shepmaster:beta-bump, r=Mark-Simulacrumbors-22/+5
Bump bootstrap compiler version r? `@Mark-Simulacrum` /cc `@pietroalbini`
2020-11-22BTreeMap: swap the names of NodeRef::new and Root::new_leafStein Somers-14/+14
2020-11-22BTreeMap: fix minor testing mistakes in #78903Stein Somers-16/+15
2020-11-22Auto merge of #79275 - integer32llc:doc-style, r=jonas-schievinkbors-8/+8
More consistently use spaces after commas in lists in docs This PR changes instances of lists that didn't use spaces after commas, like `vec![1,2,3]`, to `vec![1, 2, 3]` to be more consistent with idiomatic Rust style (the way these were looks strange to me, especially because there are often lists that *do* use spaces after the commas later in the same code block 😬). I noticed one of these in an example in the stdlib docs and went looking for more, but as far as I can see, I'm only changing those spots in user-facing documentation or rustc output, and the changes make no semantic difference.
2020-11-21Auto merge of #78461 - TimDiekmann:vec-alloc, r=Amanieubors-192/+487
Add support for custom allocators in `Vec` This follows the [roadmap](https://github.com/rust-lang/wg-allocators/issues/7) of the allocator WG to add custom allocators to collections. r? `@Amanieu` This pull request requires a crater run. ### Prior work: - #71873: Crater-test to solve rust-lang/wg-allocators#1 - [`alloc-wg`](https://github.com/TimDiekmann/alloc-wg)-crate
2020-11-21More consistently use spaces after commas in lists in docsCarol (Nichols || Goulding)-8/+8
2020-11-21Rollup merge of #77844 - RalfJung:zst-box, r=nikomatsakisDylan DPC-0/+11
clarify rules for ZST Boxes LLVM's rules around `getelementptr inbounds` with offset 0 are a bit annoying, and as a consequence we have no choice but say that a `Box<()>` pointing to previously allocated memory that has since been freed is UB. Clarify the docs to reflect this. This is based on conversations on the LLVM mailing list. * Here's my initial mail: https://lists.llvm.org/pipermail/llvm-dev/2019-February/130452.html * The first email of the March part of that thread: https://lists.llvm.org/pipermail/llvm-dev/2019-March/130831.html * First email of the April part: https://lists.llvm.org/pipermail/llvm-dev/2019-April/131693.html The conclusion for me at least was that `getelementptr inbounds` with offset 0 is *not* the identity function, but can sometimes return `poison` even when the input is a regular pointer -- specifically, it returns `poison` when this pointer points into something that LLVM "knows has been deallocated", i.e., a former LLVM-managed allocation. It is however the identity function on pointers obtained by casting integers. Note that there [are formal proposals](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf) for LLVM semantics where `getelementptr inbounds` with offset 0 isn't quite the identity function but never returns `poison` (it affects the provenance of the pointer but in a way that doesn't matter if this pointer is never used for memory accesses), and indeed this is likely necessary to consistently describe LLVM semantics. But with the informal LLVM LangRef that we have right now, and with LLVM devs insisting otherwise, it seems unwise to rely on this.
2020-11-21BTreeMap: address namespace conflictsStein Somers-35/+33
2020-11-20reference NonNull::danglingRalf Jung-4/+6
2020-11-19Bump bootstrap compiler versionJake Goulding-22/+5
2020-11-18Add support for custom allocators in `Vec`Tim Diekmann-192/+487