about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2023-01-08Rollup merge of #106562 - clubby789:vec-deque-example, r=Mark-SimulacrumYuki Okushi-1/+3
Clarify examples for `VecDeque::get/get_mut` Closes #106114 ``@rustbot`` label +A-docs
2023-01-08Auto merge of #104658 - thomcc:rand-update-and-usable-no_std, r=Mark-Simulacrumbors-8/+389
Update `rand` in the stdlib tests, and remove the `getrandom` feature from it. The main goal is actually removing `getrandom`, so that eventually we can allow running the stdlib test suite on tier3 targets which don't have `getrandom` support. Currently those targets can only run the subset of stdlib tests that exist in uitests, and (generally speaking), we prefer not to test libstd functionality in uitests, which came up recently in https://github.com/rust-lang/rust/pull/104095 and https://github.com/rust-lang/rust/pull/104185. Additionally, the fact that we can't update `rand`/`getrandom` means we're stuck with the old set of tier3 targets, so can't test new ones. ~~Anyway, I haven't checked that this actually does allow use on tier3 targets (I think it does not, as some work is needed in stdlib submodules) but it moves us slightly closer to this, and seems to allow at least finally updating our `rand` dep, which definitely improves the status quo.~~ Checked and works now. For the most part, our tests and benchmarks are fine using hard-coded seeds. A couple tests seem to fail with this (stuff manipulating the environment expecting no collisions, for example), or become pointless (all inputs to a function become equivalent). In these cases I've done a (gross) dance (ab)using `RandomState` and `Location::caller()` for some extra "entropy". Trying to share that code seems *way* more painful than it's worth given that the duplication is a 7-line function, even if the lines are quite gross. (Keeping in mind that sharing it would require adding `rand` as a non-dev dep to std, and exposing a type from it publicly, all of which sounds truly awful, even if done behind a perma-unstable feature). See also some previous attempts: - https://github.com/rust-lang/rust/pull/86963 (in particular https://github.com/rust-lang/rust/pull/86963#issuecomment-885438936 which explains why this is non-trivial) - https://github.com/rust-lang/rust/pull/89131 - https://github.com/rust-lang/rust/pull/96626#issuecomment-1114562857 (I tried in that PR at the same time, but settled for just removing the usage of `thread_rng()` from the benchmarks, since that was the main goal). - https://github.com/rust-lang/rust/pull/104185 - Probably more. It's very tempting of a thing to "just update". r? `@Mark-Simulacrum`
2023-01-07Document that `Vec::from_raw_parts[_in]` must be given a pointer from the ↵Kevin Reid-0/+5
correct allocator.
2023-01-07Rollup merge of #105128 - Sp00ph:vec_vec_deque_conversion, r=dtolnayMatthias Krüger-3/+3
Add O(1) `Vec -> VecDeque` conversion guarantee (See #105072)
2023-01-07Clarify examples for `VecDeque::get/get_mut`clubby789-1/+3
2023-01-04Update rand in the stdlib tests, and remove the getrandom feature from itThom Chiovoloni-8/+389
2023-01-04Auto merge of #106239 - LegionMammal978:thin-box-drop-guard, r=Amanieubors-13/+34
Deallocate ThinBox even if the value unwinds on drop This makes it match the behavior of an ordinary `Box`.
2023-01-03Rollup merge of #106045 - RalfJung:oom-nounwind-panic, r=AmanieuMichael Goulet-1/+15
default OOM handler: use non-unwinding panic, to match std handler The OOM handler in std will by default abort. This adjusts the default in liballoc to do the same, using the `can_unwind` flag on the panic info to indicate a non-unwinding panic. In practice this probably makes little difference since the liballoc default will only come into play in no-std situations where people write a custom panic handler, which most likely will not implement unwinding. But still, this seems more consistent. Cc `@rust-lang/wg-allocators,` https://github.com/rust-lang/rust/issues/66741
2023-01-02default OOM handler: use non-unwinding panic (unless -Zoom=panic is set), to ↵Ralf Jung-1/+15
match std handler
2023-01-01Deallocate ThinBox even if the value unwinds on dropLegionMammal978-13/+34
2022-12-30Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726Michael Goulet-2/+0
Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint" This is a clean revert of #105484. I confirmed that reverting that PR fixes the regression reported in #106247. ~~I can't say I understand what this code is doing, but maybe it can be re-landed with a different implementation.~~ **Edit:** https://github.com/rust-lang/rust/issues/106247#issuecomment-1367174384 has an explanation of why #105484 ends up surfacing spurious `where_clause_object_safety` errors. The implementation of `where_clause_object_safety` assumes we only check whether a trait is object safe when somebody actually uses that trait with `dyn`. However the implementation of `multiple_supertrait_upcastable` added in the problematic PR involves checking *every* trait for whether it is object-safe. FYI `@nbdd0121` `@compiler-errors`
2022-12-30Update paths in comments.jonathanCogan-1/+1
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-5/+5
2022-12-30Replace libstd, libcore, liballoc in docs.jonathanCogan-2/+2
2022-12-29Revert "Implement allow-by-default multiple_supertrait_upcastable lint"David Tolnay-2/+0
This reverts commit 5e44a65517bfcccbe6624a70b54b9f192baa94f3.
2022-12-29Implement more methods for `vec_deque::IntoIter`Markus Everling-1/+184
2022-12-28fix documenting private items of standard libraryLukas Markeffsky-11/+18
2022-12-28Update bootstrap cfgPietro Albini-45/+2
2022-12-28Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errorsfee1-dead-0/+2
Implement allow-by-default `multiple_supertrait_upcastable` lint The lint detects when an object-safe trait has multiple supertraits. Enabled in libcore and liballoc as they are low-level enough that many embedded programs will use them. r? `@nikomatsakis`
2022-12-28Rollup merge of #104024 - noeddl:unused-must-use, r=compiler-errorsfee1-dead-1/+1
Fix `unused_must_use` warning for `Box::from_raw`
2022-12-28Rollup merge of #94145 - ssomers:binary_heap_tests, r=jyn514fee1-dead-60/+109
Test leaking of BinaryHeap Drain iterators Add test cases about forgetting the `BinaryHeap::Drain` iterator, and slightly fortifies some other test cases. Consists of separate commits that I don't think are relevant on their own (but I'll happily turn these into more PRs if desired).
2022-12-27Update the documentation of `Vec` to use `extend(array)` instead of ↵Chayim Refael Friedman-1/+1
`extend(array.iter().copied())`
2022-12-23fix one more unaligned self.ptr, and add testsRalf Jung-1/+1
2022-12-23fix IntoIter::drop on high-alignment ZSTRalf Jung-10/+11
2022-12-20Auto merge of #105127 - Sp00ph:const_new, r=dtolnaybors-3/+4
Make `VecDeque::new` const (See #105072)
2022-12-19Update coerce_unsized tracking issue from #27732 to #18598Anders Kaseorg-5/+5
Issue #27732 was closed as a duplicate of #18598. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-12-17std::fmt: Use args directly in example codeEvan Jones-2/+2
The lint "clippy::uninlined_format_args" recommends inline variables in format strings. Fix two places in the docs that do not do this. I noticed this because I copy/pasted one example in to my project, then noticed this lint error. This fixes: error: variables can be used directly in the `format!` string --> src/main.rs:30:22 | 30 | let string = format!("{:.*}", decimals, magnitude); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: variables can be used directly in the `format!` string --> src/main.rs:39:2 | 39 | write!(&mut io::stdout(), "{}", args).unwrap();
2022-12-15doc: Fix a few small issuesHannes Körber-1/+1
* A few typos around generic types (`;` vs `,`) * Use inline code formatting for code fragments * One instance of wrong wording
2022-12-08Apply review feedback; Fix no_global_oom_handling buildScott McMurray-0/+5
2022-12-09Implement allow-by-default multiple_supertrait_upcastable lintGary Guo-0/+2
2022-12-08Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`Scott McMurray-11/+98
2022-12-05Add O(1) `Vec -> VecDeque` conversion guaranteeMarkus Everling-3/+3
2022-12-05Auto merge of #105046 - scottmcm:vecdeque-vs-vec, r=Mark-Simulacrumbors-5/+12
Send `VecDeque::from_iter` via `Vec::from_iter` Since it's O(1) to convert between them now, might as well reuse the logic. Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
2022-12-03Rollup merge of #105032 - HintringerFabian:improve_docs, r=JohnTitorYuki Okushi-1/+10
improve doc of into_boxed_slice and impl From<Vec<T>> for Box<[T]> Improves description of `into_boxed_slice`, and adds example to `impl From<Vec<T>> for Box<[T]>`. Fixes #98908
2022-12-01Fix typo in commentMarkus Everling-1/+1
2022-12-01Make `VecDeque::new` constMarkus Everling-3/+4
2022-12-01Make `VecDeque::new_in` unstably constMarkus Everling-2/+1
2022-11-29Send `VecDeque::from_iter` via `Vec::from_iter`Scott McMurray-5/+12
Since it's O(1) to convert between them now, might as well reuse the logic. Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
2022-11-28improve docFabian Hintringer-1/+10
2022-11-28Auto merge of #102991 - Sp00ph:master, r=scottmcmbors-1277/+925
Update VecDeque implementation to use head+len instead of head+tail (See #99805) This changes `alloc::collections::VecDeque`'s internal representation from using head and tail indices to using a head index and a length field. It has a few advantages over the current design: * It allows the buffer to be of length 0, which means the `VecDeque::new` new longer has to allocate and could be changed to a `const fn` * It allows the `VecDeque` to fill the buffer completely, unlike the old implementation, which always had to leave a free space * It removes the restriction for the size to be a power of two, allowing it to properly `shrink_to_fit`, unlike the old `VecDeque` * The above points also combine to allow the `Vec<T> -> VecDeque<T>` conversion to be very cheap and guaranteed O(1). I mention this in the `From<Vec<T>>` impl, but it's not a strong guarantee just yet, as that would likely need some form of API change proposal. All the tests seem to pass for the new `VecDeque`, with some slight adjustments. r? `@scottmcm`
2022-11-26Add second test case in `make_contiguous_head_to_end`Markus Everling-10/+49
2022-11-26Improve slow path in `make_contiguous`Markus Everling-36/+76
2022-11-26Don't use `Take` in `SpecExtend` implMarkus Everling-21/+23
2022-11-24Tune RepeatWith::try_fold and Take::for_each and Vec::extend_trustedScott McMurray-5/+9
2022-11-25Changes according to code reviewMarkus Everling-144/+181
2022-11-24Stop peeling the last iteration of the loop in `Vec::repeat_with`Scott McMurray-11/+1
2022-11-24Extract the logic for `TrustedLen` to a named method that can be called directlyScott McMurray-32/+37
2022-11-22Rollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomccManish Goregaokar-0/+1
enable fuzzy_provenance_casts lint in liballoc and libstd r? ````@thomcc````
2022-11-22Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnayManish Goregaokar-1/+1
Make the Box one-liner more descriptive I would like to avoid a definition that relies on itself. r? `@GuillaumeGomez`
2022-11-21Touch up Box<T> one-linerDavid Tolnay-2/+2