about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2024-01-20chore: add tracking issue number to local waker featureTomás Vallotton-10/+12
2024-01-20fix: make LocalWake available in targets that don't support atomics by ↵Tomás Vallotton-8/+12
removing a #[cfg(target_has_atomic = ptr)]
2024-01-20feat: add try_waker and From<&mut Context> for ContextBuilder to allow the ↵Tomás Vallotton-9/+11
extention of contexts by futures
2024-01-20feat: add LocalWaker type, ContextBuilder type, and LocalWake trait.Tomás Vallotton-1/+165
2024-01-19fix: Drop guard was deallocating with the incorrect sizeThe 8472-13/+25
InPlaceDstBufDrop holds onto the allocation before the shrinking happens which means it must deallocate the destination elements but the source allocation.
2024-01-19Rollup merge of #120110 - invpt:patch-1, r=the8472Matthias Krüger-7/+12
Update documentation for Vec::into_boxed_slice to be more clear about excess capacity Currently, the documentation for Vec::into_boxed_slice says that "if the vector has excess capacity, its items will be moved into a newly-allocated buffer with exactly the right capacity." This is misleading, as copies do not necessarily occur, depending on if the allocator supports in-place shrinking. I copied some of the wording from shrink_to_fit, though it could potentially still be worded better than this.
2024-01-18Clarify docs for Vec::into_boxed_slice, Vec::shrink_to_fitinvpt-7/+12
2024-01-18remove alignment-changing in-place collectThe 8472-5/+8
Currently stable users can't benefit from this because GlobaAlloc doesn't support alignment-changing realloc and neither do most posix allocators. So in practice it always results in an extra memcpy.
2024-01-18update internal ASCII art comment for vec specializationsThe 8472-7/+7
2024-01-18Remove no-longer-needed `allow(dead_code)` from the standard libraryJake Goulding-1/+0
`repr(transparent)` now silences the lint.
2024-01-18Add `A: 'static` bound for `Arc/Rc::pin_in`zetanumbers-3/+12
2024-01-16Fix typo in comments (in_place_collect)Robert Grosse-1/+1
2024-01-13libs: use `assert_unchecked` instead of intrinsicjoboet-10/+12
2024-01-13Remove special-case handling of `vec.split_off(0)`Zalathar-8/+0
2024-01-11chore: remove unnecessary blank linehi-rustin-1/+0
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-01-10Fix deallocation with wrong allocator in (A)Rc::from_box_inzachs18-2/+2
2024-01-08rc,sync: Do not create references to uninitialized valuesTaiki Endo-20/+25
2024-01-07mark vec::IntoIter pointers as `!nonnull`The 8472-49/+75
2024-01-07typo fixThe 8472-1/+1
2024-01-06Rollup merge of #118781 - RalfJung:core-panic-feature, r=the8472Matthias Krüger-1/+1
merge core_panic feature into panic_internals I don't know why those are two separate features, but it does not seem intentional. This merge is useful because with https://github.com/rust-lang/rust/pull/118123, panic_internals is recognized as an internal feature, but core_panic is not -- but core_panic definitely should be internal.
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-3/+4
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-03Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-SimulacrumLeón Orell Valerian Liehr-3/+3
rc: Take *const T in is_dangling It is not important which one is used since `is_dangling` does not access memory, but `*const` removes the needs of `*const T` -> `*mut T` casts in `from_raw_in`.
2024-01-02Adjust library tests for unused_tuple_struct_fields -> dead_codeJake Goulding-3/+4
2023-12-30Rollup merge of #119158 - JohnTheCoolingFan:arc-weak-clone-pretty, r=cuviperMatthias Krüger-14/+11
Clean up alloc::sync::Weak Clone implementation Since both return points (tail and early return) return the same expression and the only difference is whether inner is available, the code that does the atomic operations and checks on inner was moved into the if body and the only return is at the tail. Original comments preserved.
2023-12-30rc: Take *const T in is_danglingTaiki Endo-3/+3
It is not important which one is used since `is_dangling` does not access memory, but `*const` removes the needs of `*const T` -> `*mut T` casts in `from_raw_in`.
2023-12-29Italicise "bytes" in the docs of some `Vec` methodsGurinder Singh-8/+8
because on a cursory read it's easy to miss that the limit is in terms of bytes not no. of elements. The italics should help with that.
2023-12-24Rollup merge of #119205 - mumbleskates:vecdeque-comment-fix, r=Mark-SimulacrumMatthias Krüger-4/+4
fix minor mistake in comments describing VecDeque resizing Avoiding confusion where one of the items in the deque seems to disappear in two of the three cases
2023-12-22update version placeholdersPietro Albini-2/+2
2023-12-21fix minor mistake in comments describing VecDeque resizingKent Ross-4/+4
2023-12-20Cleaned up alloc::sync::Weak Clone implementationJohnTheCoolingFan-14/+11
Since both return points (tail and early return) return the same expression and the only difference is whether inner is available, the code that does the atomic operations and checks on inner was moved into the if body and the only return is at the tail. Original comments preserved.
2023-12-20Auto merge of #106790 - the8472:rawvec-niche, r=scottmcmbors-15/+50
add more niches to rawvec Previously RawVec only had a single niche in its `NonNull` pointer. With this change it now has `isize::MAX` niches since half the value-space of the capacity field is never needed, we can't have a capacity larger than isize::MAX.
2023-12-14Update c_str.rsDaniel Huang-3/+3
2023-12-11add comment to RawVec::cap fieldThe 8472-0/+5
2023-12-11add more niches to rawvecThe 8472-15/+45
2023-12-10Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkovbors-31/+3
remove redundant imports detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR. r? `@petrochenkov`
2023-12-10Auto merge of #116949 - hamza1311:stablize-arc_unwrap_or_clone, r=dtolnaybors-4/+2
Stablize arc_unwrap_or_clone Fixes: #93610 This likely needs FCP. I created this PR as it's stabilization is trivial and FCP can be just conducted here. Not sure how to ping the libs API team (last attempt didn't work apparently according to GH UI)
2023-12-10remove redundant importssurechen-31/+3
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09merge core_panic feature into panic_internalsRalf Jung-1/+1
2023-12-09Auto merge of #114136 - TennyZhuang:linked-list-retain, r=thomccbors-0/+93
add LinkedList::{retain,retain_mut} Implement #114135 The API is consistent with other collections.
2023-12-07Auto merge of #117960 - zhiqiangxu:dry, r=workingjubileebors-5/+3
chore: avoid duplicate code in `Weak::inner`
2023-12-06Rollup merge of #117563 - 0xalpharush:docs/into-raw, r=workingjubileeMatthias Krüger-3/+11
docs: clarify explicitly freeing heap allocated memory The documentation for `Box::into_raw` didn't mention `drop` and wondered if I was doing something wrong. Based off [this](https://stackoverflow.com/questions/75441199/rust-how-do-i-correctly-free-heap-allocated-memory), I think it's helpful to include the more concise yet explicit way to free heap allocated memory. This is my first rust PR and I went through https://std-dev-guide.rust-lang.org/development/, but let me know if I missed something :)
2023-12-06Auto merge of #118460 - the8472:fix-vec-realloc, r=saethlinbors-7/+27
Fix in-place collect not reallocating when necessary Regression introduced in https://github.com/rust-lang/rust/pull/110353. This was [caught by miri](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Cron.20Job.20Failure.20.28miri-test-libstd.2C.202023-11.29/near/404764617) r? `@saethlin`
2023-12-06Don't repeat yourselfzhiqiangxu-5/+3
2023-12-05Auto merge of #118273 - AngelicosPhosphoros:dedup_2_loops_version_77772_2, ↵bors-12/+45
r=the8472 Split `Vec::dedup_by` into 2 cycles First cycle runs until we found 2 same elements, second runs after if there any found in the first one. This allows to avoid any memory writes until we found an item which we want to remove. This leads to significant performance gains if all `Vec` items are kept: -40% on my benchmark with unique integers. Results of benchmarks before implementation (including new benchmark where nothing needs to be removed): * vec::bench_dedup_all_100 74.00ns/iter +/- 13.00ns * vec::bench_dedup_all_1000 572.00ns/iter +/- 272.00ns * vec::bench_dedup_all_100000 64.42µs/iter +/- 19.47µs * __vec::bench_dedup_none_100 67.00ns/iter +/- 17.00ns__ * __vec::bench_dedup_none_1000 662.00ns/iter +/- 86.00ns__ * __vec::bench_dedup_none_10000 9.16µs/iter +/- 2.71µs__ * __vec::bench_dedup_none_100000 91.25µs/iter +/- 1.82µs__ * vec::bench_dedup_random_100 105.00ns/iter +/- 11.00ns * vec::bench_dedup_random_1000 781.00ns/iter +/- 10.00ns * vec::bench_dedup_random_10000 9.00µs/iter +/- 5.62µs * vec::bench_dedup_random_100000 449.81µs/iter +/- 74.99µs * vec::bench_dedup_slice_truncate_100 105.00ns/iter +/- 16.00ns * vec::bench_dedup_slice_truncate_1000 2.65µs/iter +/- 481.00ns * vec::bench_dedup_slice_truncate_10000 18.33µs/iter +/- 5.23µs * vec::bench_dedup_slice_truncate_100000 501.12µs/iter +/- 46.97µs Results after implementation: * vec::bench_dedup_all_100 75.00ns/iter +/- 9.00ns * vec::bench_dedup_all_1000 494.00ns/iter +/- 117.00ns * vec::bench_dedup_all_100000 58.13µs/iter +/- 8.78µs * __vec::bench_dedup_none_100 52.00ns/iter +/- 22.00ns__ * __vec::bench_dedup_none_1000 417.00ns/iter +/- 116.00ns__ * __vec::bench_dedup_none_10000 4.11µs/iter +/- 546.00ns__ * __vec::bench_dedup_none_100000 40.47µs/iter +/- 5.36µs__ * vec::bench_dedup_random_100 77.00ns/iter +/- 15.00ns * vec::bench_dedup_random_1000 681.00ns/iter +/- 86.00ns * vec::bench_dedup_random_10000 11.66µs/iter +/- 2.22µs * vec::bench_dedup_random_100000 469.35µs/iter +/- 20.53µs * vec::bench_dedup_slice_truncate_100 100.00ns/iter +/- 5.00ns * vec::bench_dedup_slice_truncate_1000 2.55µs/iter +/- 224.00ns * vec::bench_dedup_slice_truncate_10000 18.95µs/iter +/- 2.59µs * vec::bench_dedup_slice_truncate_100000 492.85µs/iter +/- 72.84µs Resolves #77772 P.S. Note that this is same PR as #92104 I just missed review then forgot about it. Also, I cannot reopen that pull request so I am creating a new one. I responded to remaining questions directly by adding commentaries to my code.
2023-12-05Split `Vec::dedup_by` into 2 cyclesAngelicosPhosphoros-12/+45
First cycle runs until we found 2 same elements, second runs after if there any found in the first one. This allows to avoid any memory writes until we found an item which we want to remove. This leads to significant performance gains if all `Vec` items are kept: -40% on my benchmark with unique integers. Results of benchmarks before implementation (including new benchmark where nothing needs to be removed): * vec::bench_dedup_all_100 74.00ns/iter +/- 13.00ns * vec::bench_dedup_all_1000 572.00ns/iter +/- 272.00ns * vec::bench_dedup_all_100000 64.42µs/iter +/- 19.47µs * __vec::bench_dedup_none_100 67.00ns/iter +/- 17.00ns__ * __vec::bench_dedup_none_1000 662.00ns/iter +/- 86.00ns__ * __vec::bench_dedup_none_10000 9.16µs/iter +/- 2.71µs__ * __vec::bench_dedup_none_100000 91.25µs/iter +/- 1.82µs__ * vec::bench_dedup_random_100 105.00ns/iter +/- 11.00ns * vec::bench_dedup_random_1000 781.00ns/iter +/- 10.00ns * vec::bench_dedup_random_10000 9.00µs/iter +/- 5.62µs * vec::bench_dedup_random_100000 449.81µs/iter +/- 74.99µs * vec::bench_dedup_slice_truncate_100 105.00ns/iter +/- 16.00ns * vec::bench_dedup_slice_truncate_1000 2.65µs/iter +/- 481.00ns * vec::bench_dedup_slice_truncate_10000 18.33µs/iter +/- 5.23µs * vec::bench_dedup_slice_truncate_100000 501.12µs/iter +/- 46.97µs Results after implementation: * vec::bench_dedup_all_100 75.00ns/iter +/- 9.00ns * vec::bench_dedup_all_1000 494.00ns/iter +/- 117.00ns * vec::bench_dedup_all_100000 58.13µs/iter +/- 8.78µs * __vec::bench_dedup_none_100 52.00ns/iter +/- 22.00ns__ * __vec::bench_dedup_none_1000 417.00ns/iter +/- 116.00ns__ * __vec::bench_dedup_none_10000 4.11µs/iter +/- 546.00ns__ * __vec::bench_dedup_none_100000 40.47µs/iter +/- 5.36µs__ * vec::bench_dedup_random_100 77.00ns/iter +/- 15.00ns * vec::bench_dedup_random_1000 681.00ns/iter +/- 86.00ns * vec::bench_dedup_random_10000 11.66µs/iter +/- 2.22µs * vec::bench_dedup_random_100000 469.35µs/iter +/- 20.53µs * vec::bench_dedup_slice_truncate_100 100.00ns/iter +/- 5.00ns * vec::bench_dedup_slice_truncate_1000 2.55µs/iter +/- 224.00ns * vec::bench_dedup_slice_truncate_10000 18.95µs/iter +/- 2.59µs * vec::bench_dedup_slice_truncate_100000 492.85µs/iter +/- 72.84µs Resolves #77772
2023-12-05Fix in-place collect not reallocating when necessaryThe 8472-7/+27
2023-12-04Remove useless `'static` bounds on `Box` allocatorJules Bertholet-9/+3
#79327 added `'static` bounds to the allocator parameter for various `Box` + `Pin` APIs to ensure soundness. But it was a bit overzealous, some of the bounds aren't actually needed.
2023-11-29Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgrbors-0/+11
Rollup of 7 pull requests Successful merges: - #116839 (Implement thread parking for xous) - #118265 (remove the memcpy-on-equal-ptrs assumption) - #118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`) - #118394 (Remove HIR opkinds) - #118398 (Add proper cfgs in std) - #118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context) - #118422 (Fix coroutine validation for mixed panic strategy) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-29Rollup merge of #118383 - ↵Matthias Krüger-0/+1
shepmaster:unused-tuple-struct-field-cleanup-stdlib, r=m-ou-se Address unused tuple struct fields in the standard library
2023-11-29Rollup merge of #118398 - mu001999:std/add_cfgs, r=thomccMatthias Krüger-0/+11
Add proper cfgs in std Detected by #118257