about summary refs log tree commit diff
path: root/library/alloc/src/collections
AgeCommit message (Collapse)AuthorLines
2024-09-20Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errorsbors-0/+6
Disallow hidden references to mutable static Closes #123060 Tracking: - https://github.com/rust-lang/rust/issues/123758
2024-09-20Add `#[track_caller]` to allocating methods of `Vec` & `VecDeque`Pavel Grigorenko-0/+31
2024-09-19[Clippy] Swap `map_entry` to use diagnostic items instead of pathsGnomedDev-0/+2
2024-09-18[Clippy] Swap `manual_retain` to use diagnostic items instead of pathsGnomedDev-0/+3
2024-09-13Update tests for hidden references to mutable staticObei Sideg-0/+6
2024-09-12Rollup merge of #130101 - RalfJung:const-cleanup, r=fee1-deadMatthias Krüger-2/+2
some const cleanup: remove unnecessary attributes, add const-hack indications I learned that we use `FIXME(const-hack)` on top of the "const-hack" label. That seems much better since it marks the right place in the code and moves around with the code. So I went through the PRs with that label and added appropriate FIXMEs in the code. IMO this means we can then remove the label -- Cc ``@rust-lang/wg-const-eval.`` I also noticed some const stability attributes that don't do anything useful, and removed them. r? ``@fee1-dead``
2024-09-08add FIXME(const-hack)Ralf Jung-2/+2
2024-09-08Remove needless returns detected by clippy in librariesEduardo Sánchez Muñoz-4/+4
2024-09-07Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68bors-9/+5
Bump boostrap compiler to new beta Accidentally left some comments on the update cfgs commit directly xd
2024-09-05update cfgsBoxy-4/+0
2024-09-05Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-SimulacrumMatthias Krüger-1/+1
enable -Zrandomize-layout in debug CI builds This builds rustc/libs/tools with `-Zrandomize-layout` on *-debug CI runners. Only a handful of tests and asserts break with that enabled, which is promising. One test was fixable, the rest is dealt with by disabling them through new cargo features or compiletest directives. The config.toml flag `rust.randomize-layout` defaults to false, so it has to be explicitly enabled for now.
2024-09-03replace placeholder versionBoxy-5/+5
2024-08-31when -Zrandomize-layout is enabled disable alloc test testing internal ↵The 8472-1/+1
struct sizes
2024-08-31Fixed typos in btree map docsranger-ross-4/+4
2024-08-10Stabilize `min_exhaustive_patterns`Nadrieril-0/+2
2024-08-07Rollup merge of #128261 - clarfonthey:iter-default, r=dtolnayMatthias Krüger-0/+70
impl `Default` for collection iterators that don't already have it There is a pretty strong precedent for implementing `Default` for collection iterators, and this does so for some where this implementation was missed. I don't think this needs a separate ACP (since this precedent already exists, and these feel like they were just missed), however, it *will* need an FCP since these implementations are instantly stable.
2024-08-05Rollup merge of #128309 - kmicklas:btreeset-cursor, r=AmanieuMatthias Krüger-1/+582
Implement cursors for `BTreeSet` Tracking issue: https://github.com/rust-lang/rust/issues/107540 This is a straightforward wrapping of the map API, except that map's `CursorMut` does not make sense, because there is no value to mutate. Hence, map's `CursorMutKey` is wrapped here as just `CursorMut`, since it's unambiguous for sets and we don't normally speak of "keys". On the other hand, I can see some potential for confusion with `CursorMut` meaning different things in each module. I'm happy to take suggestions to improve that. r? ````@Amanieu````
2024-08-01Fix mutability in doc tests for `BTreeSet` cursorsKen Micklas-10/+10
2024-08-01Introduce `Cursor`/`CursorMut`/`CursorMutKey` thrichotomy for `BTreeSet` ↵Ken Micklas-16/+194
like map API
2024-08-01Fix some uses of "map" instead of "set" in `BTreeSet` cursor API docsKen Micklas-4/+4
2024-08-01Share `UnorderedKeyError` with `BTReeMap` for set APIKen Micklas-29/+7
2024-07-29Rollup merge of #128310 - kmicklas:btree-map-peek-next-docs, r=tgross35Matthias Krüger-3/+3
Add missing periods on `BTreeMap` cursor `peek_next` docs Tracking issue: https://github.com/rust-lang/rust/issues/107540
2024-07-29Reformat `use` declarations.Nicholas Nethercote-68/+67
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Add missing periods on `BTreeMap` cursor `peek_next` docsKen Micklas-3/+3
2024-07-28Implement cursors for `BTreeSet`Ken Micklas-1/+426
2024-07-27Okay, I guess I have to give these a different feature nameltdk-5/+5
2024-07-27impl Default for collection iterators that don't already have itltdk-0/+70
2024-07-26Fix doc nitsJohn Arundel-1/+3
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-24Rollup merge of #125962 - Coekjan:const-binary-heap, r=AmanieuMatthias Krüger-1/+1
Update tracking issue for `const_binary_heap_new_in` This PR updates the tracking issue of `const_binary_heap_new_in` feature: - Old issue: #112353 - New issue: #125961
2024-07-08Rollup merge of #127355 - aceArt-GmbH:126475, r=oli-obkMatthias Krüger-12/+12
Mark format! with must_use hint Uses unstable feature https://github.com/rust-lang/rust/issues/94745 Part of #126475 First contribution to rust, please let me know if the blessing of tests is correct Thanks `@bjorn3` for the help
2024-07-07Auto merge of #127454 - matthiaskrgr:rollup-k3vfen2, r=matthiaskrgrbors-0/+20
Rollup of 8 pull requests Successful merges: - #127179 (Print `TypeId` as hex for debugging) - #127189 (LinkedList's Cursor: method to get a ref to the cursor's list) - #127236 (doc: update config file path in platform-support/wasm32-wasip1-threads.md) - #127297 (Improve std::Path's Hash quality by avoiding prefix collisions) - #127308 (Attribute cleanups) - #127354 (Describe Sized requirements for mem::offset_of) - #127409 (Emit a wrap expr span_bug only if context is not tainted) - #127447 (once_lock: make test not take as long in Miri) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-07Specialize `TrustedLen` for `Iterator::unzip()`Chayim Refael Friedman-11/+32
Don't check the capacity every time (and also for `Extend` for tuples, as this is how `unzip()` is implemented). I did this with an unsafe method on `Extend` that doesn't check for growth (`extend_one_unchecked()`). I've marked it as perma-unstable currently, although we may want to expose it in the future so collections outside of std can benefit from it. Then specialize `Extend for (A, B)` for `TrustedLen` to call it. It may seem that an alternative way of implementing this is to have a semi-public trait (`#[doc(hidden)]` public, so collections outside of core can implement it) for `extend()` inside tuples, and specialize it from collections. However, it is impossible due to limitations of `min_specialization`. A concern that may arise with the current approach is that implementing `extend_one_unchecked()` correctly must also incur implementing `extend_reserve()`, otherwise you can have UB. This is a somewhat non-local safety invariant. However, I believe this is fine, since to have actual UB you must have unsafe code inside your `extend_one_unchecked()` that makes incorrect assumption, *and* not implement `extend_reserve()`. I've also documented this requirement.
2024-07-06Mark format! with must_use hintlukas-12/+12
2024-07-01LinkedList's Cursor: method to get a ref to the cursor's listPavel Grigorenko-0/+20
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-1/+1
This is possible now that inline const blocks are stable; the idea was even mentioned as an alternative when `uninit_array()` was added: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a > standard library method that will be replaceable with > `let buffer = [MaybeUninit::<T>::uninit(); $N];` Const array repetition and inline const blocks are now stable (in the next release), so that circumstance has come to pass, and we no longer have reason to want `uninit_array()` other than convenience. Therefore, let’s evaluate the inconvenience by not using `uninit_array()` in the standard library, before potentially deleting it entirely.
2024-06-11replace version placeholderPietro Albini-5/+2
2024-06-07Rollup merge of #124012 - slanterns:as_slice_stabilize, r=BurntSushiMatthias Krüger-2/+1
Stabilize `binary_heap_as_slice` This PR stabilizes `binary_heap_as_slice`: ```rust // std::collections::BinaryHeap impl BinaryHeap<T> { pub fn as_slice(&self) -> &[T] } ``` <br> Tracking issue: https://github.com/rust-lang/rust/issues/83659. Implementation PR: https://github.com/rust-lang/rust/pull/82331. FCPs already completed in the tracking issue. Closes https://github.com/rust-lang/rust/issues/83659. r? libs-api
2024-06-04Make deleting on LinkedList aware of the allocatorAndrei Damian-2/+41
2024-06-04update tracking issue for `const_binary_heap_new_in`coekjan-1/+1
2024-06-01stablize `const_binary_heap_constructor` & create an unstable feature ↵coekjan-2/+5
`const_binary_heap_new_in` for `BinaryHeap::new_in`
2024-05-07Move `test_shrink_to_unwind` to its own file.Markus Everling-54/+1
This way, no other test can be tripped up by `test_shrink_to_unwind` changing the alloc error hook.
2024-05-07Fix `VecDeque::shrink_to` UB when `handle_alloc_error` unwinds.Markus Everling-2/+119
Luckily it's comparatively simple to just restore the `VecDeque` into a valid state on unwinds.
2024-04-24fix typo in binary_heap docsThomas Lindae-1/+1
2024-04-17Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnayMatthias Krüger-12/+28
Document overrides of `clone_from()` in core/std As mentioned in https://github.com/rust-lang/rust/pull/96979#discussion_r1379502413 Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source". I reused some of the wording over and over for similar impls, but I'm not sure that the wording is actually *good*. Would appreciate feedback about that. Also, now some of these seem to provide pretty specific guarantees about behavior (e.g. will reuse the exact same allocation iff the len is the same), but I was basing it off of the docs for [`Box::clone_from`](https://doc.rust-lang.org/1.75.0/std/boxed/struct.Box.html#method.clone_from-1) - I'm not sure if providing those strong guarantees is actually good or not.
2024-04-17Address commentsNoa-3/+1
2024-04-16Stabilize `BinaryHeap::as_slice`Slanterns-2/+1
2024-04-15Add vec_deque::Iter::as_slices and friendschloekek-0/+141
Add the following methods, that work similarly to VecDeque::as_slices: - alloc::collections::vec_deque::Iter::as_slices - alloc::collections::vec_deque::IterMut::into_slices - alloc::collections::vec_deque::IterMut::as_slices - alloc::collections::vec_deque::IterMut::as_mut_slices Obtaining slices from a VecDeque iterator was not previously possible.
2024-04-08Add invariant to VecDeque::pop_* that len < cap if pop successfulPhilippe-Cholet-2/+8
Similar to #114370 for VecDeque instead of Vec. It now uses `core::hint::assert_unchecked`.
2024-04-02Auto merge of #122945 - andy-k:sorted-vec-example, r=jhprattbors-2/+4
improve example on inserting to a sorted vector to avoid shifting equal elements
2024-03-28Rename reserve_for_push to grow_one and fix comment.Cai Bear-1/+1