summary refs log tree commit diff
path: root/library/alloc
AgeCommit message (Collapse)AuthorLines
2020-08-24Auto merge of #75815 - jyn514:ambiguous-primitives, r=guillaumegomezbors-5/+7
Report an ambiguity if both modules and primitives are in scope for intra-doc links Closes https://github.com/rust-lang/rust/issues/75381 - Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace - Refactor `report_ambiguity` into a closure Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case. I also need to update libstd to use `prim@char` instead of `type@char`. If possible I would also like to refactor `ambiguity_error` to use `Disambiguator` instead of its own hand-rolled match - that ran into issues with `prim@` (I updated one and not the other) and it would be better for them to be in sync.
2020-08-24Auto merge of #75505 - Dylan-DPC:feature/arc_new, r=KodrAusbors-4/+147
Add Arc::new_cyclic Rework of #72443 References #75861 cc @Diggsey @RalfJung r? @KodrAus
2020-08-24Rollup merge of #75831 - lzutao:https, r=Dylan-DPCYuki Okushi-3/+3
doc: Prefer https link for wikipedia URLs A tiny changes.
2020-08-23Convert from str -> prim@str for `alloc`Joshua Nelson-5/+7
2020-08-24add issue numberDylan DPC-1/+1
2020-08-23Auto merge of #74238 - RalfJung:offset_from, r=oli-obkbors-1/+0
stabilize ptr_offset_from This stabilizes ptr::offset_from, and closes https://github.com/rust-lang/rust/issues/41079. It also removes the deprecated `wrapping_offset_from`. This function was deprecated 19 days ago and was never stable; given an FCP of 10 days and some waiting time until FCP starts, that leaves at least a month between deprecation and removal which I think is fine for a nightly-only API. Regarding the open questions in https://github.com/rust-lang/rust/issues/41079: * Should offset_from abort instead of panic on ZSTs? -- As far as I know, there is no precedent for such aborts. We could, however, declare this UB. Given that the size is always known statically and the check thus rather cheap, UB seems excessive. * Should there be more methods like this with different restrictions (to allow nuw/nsw, perhaps) or that return usize (like how isize-taking offset is more conveniently done with usize-taking add these days)? -- No reason to block stabilization on that, we can always add such methods later. Also nominating the lang team because this exposes an intrinsic. The stabilized method is best described [by its doc-comment](https://github.com/RalfJung/rust/blob/56d4b2d69abb93e4f0ca79471deca7aaaaeca214/src/libcore/ptr/const_ptr.rs#L227). The documentation forgot to mention the requirement that both pointers must "have the same provenance", aka "be derived from pointers to the same allocation", which I am adding in this PR. This is a precondition that [Miri already implements](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a3b9d0a07a01321f5202cd99e9613480) and that, should LLVM ever obtain a `psub` operation to subtract pointers, will likely be required for that operation (following the semantics in [this paper](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf)).
2020-08-23Prefer https link for wikipedia URLsLzu Tao-3/+3
2020-08-22Auto merge of #75171 - amosonn:new_zeroed_slice, r=Amanieubors-30/+139
New zeroed slice Add to #63291 the methods ```rust impl<T> Box<[T]> { pub fn new_zeroed_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} } impl<T> Rc<[T]> { pub fn new_zeroed_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} } impl<T> Arc<[T]> { pub fn new_zeroed_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} } ``` as suggested in https://github.com/rust-lang/rust/issues/63291#issuecomment-605511675 . Also optimize `{Rc, Arc}::new_zeroed` to use `alloc_zeroed`, otherwise they are no more efficient than using `new_uninit` and zeroing the memory manually (which was the original implementation).
2020-08-22stabilize ptr_offset_fromRalf Jung-1/+0
2020-08-22Rollup merge of #75725 - LeSeulArtichaut:alloc-intra-doc, r=jyn514Dylan DPC-223/+116
Use intra-doc-links in `alloc` I didn't have time to test this, so I will let the CI do it for me. r? @jyn514 cc #75080
2020-08-21Update rc.rsamosonn-1/+1
2020-08-21Apply suggestions from code reviewLeSeulArtichaut-14/+6
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-21Use intra-doc-links in `alloc`LeSeulArtichaut-220/+121
2020-08-20Rollup merge of #75733 - pickfire:patch-3, r=matkladJosh Stone-64/+15
Remove duplicated alloc vec bench push_all_move push_all_move is the same as extend
2020-08-20Rollup merge of #75672 - kofls:intradoc-fix, r=jyn514Josh Stone-48/+30
Move to intra-doc links for task.rs and vec.rs Partial fix for #75080 links for [`get`], [`get_mut`] skipped due to #75643 link for [`copy_from_slice`] skipped due to #63351
2020-08-20Liballoc bench rename push_all extend_from_sliceIvan Tham-15/+15
2020-08-20Remove duplicated alloc vec bench push_all_moveIvan Tham-49/+0
push_all_move is the same as extend
2020-08-19Auto merge of #75480 - ssomers:btree_check_invariant, r=Mark-Simulacrumbors-41/+302
BTreeMap: check some invariants in unit tests
2020-08-19Apply suggestions from code reviewSurya Midatala-13/+12
2020-08-19Auto merge of #75677 - cuviper:shrink-towel, r=Mark-Simulacrumbors-1/+4
Don't panic in Vec::shrink_to_fit We can help the compiler see that `Vec::shrink_to_fit` will never reach the panic case in `RawVec::shrink_to_fit`, just by guarding the call only for cases where the capacity is strictly greater. A capacity less than the length is only possible through an unsafe call to `set_len`, which would break the `Vec` invariants, so `shrink_to_fit` can just ignore that. This removes the panicking code from the examples in both #71861 and #75636.
2020-08-18Don't panic in Vec::shrink_to_fitJosh Stone-1/+4
2020-08-18Move to intra-doc links for task.rs and vec.rsSurya Midatala-36/+19
2020-08-18Make `grow_impl` unsafeTim Diekmann-3/+6
2020-08-18BTreeMap: check some invariants, avoid recursion in depth first searchStein Somers-41/+302
2020-08-18Clean up AllocRef implementation and documentationTim Diekmann-74/+71
2020-08-17Fix typo in commentTim Diekmann-2/+2
2020-08-17Remove fast path in reallocation for same layout sizesTim Diekmann-17/+10
2020-08-15Auto merge of #75488 - ssomers:btree_revert_75257, r=Mark-Simulacrumbors-49/+20
Revert the fundamental changes in #74762 and #75257 Before possibly going over to #75487. Also contains some added and fixed comments. r? @Mark-Simulacrum
2020-08-15tidy upDPC-23/+23
2020-08-14Rollup merge of #75531 - ssomers:btree_tests_migration, r=Mark-SimulacrumTyler Mandry-56/+68
Migrate unit tests of btree collections to their native breeding ground There's one BTreeSet test case that I couldn't easily convince to come along, maybe because it truly is an integration test. But leaving it in place would mean git wouldn't see the move so I also moved it to a new file. r? @Mark-Simulacrum
2020-08-14Rollup merge of #75519 - ssomers:btree_splitpoint_cleanup, r=Mark-SimulacrumTyler Mandry-31/+37
BTreeMap: refactor splitpoint and move testing over to unit test r? @Mark-Simulacrum
2020-08-14Rollup merge of #75195 - ssomers:btree_split_up_into_kv_mut, r=Mark-SimulacrumTyler Mandry-9/+19
BTreeMap: purge innocent use of into_kv_mut Replace the use of `into_kv_mut` into more precise calls. This makes more sense if you know that the single remaining use of `into_kv_mut` is in fact evil and can be trialled in court (#75200) and sent to a correction facility (#73971). No real performance difference reported (but functions that might benefit a tiny constant bit like `BTreeMap::get_mut` aren't benchmarked): ``` benchcmp old new --threshold 5 name old ns/iter new ns/iter diff ns/iter diff % speedup btree::map::clone_fat_100 63,073 59,256 -3,817 -6.05% x 1.06 btree::map::iter_100 3,514 3,235 -279 -7.94% x 1.09 ```
2020-08-14Rollup merge of #74185 - pickfire:liballoc-iter-doc, r=jyn514Tyler Mandry-12/+3
Remove liballoc unneeded explicit link
2020-08-14Move btree unit test to their native, privileged locationStein Somers-56/+68
2020-08-14BTreeMap: refactor splitpoint and move testing over to unit testStein Somers-31/+37
2020-08-14BTreeMap: refactor splitpoint and move testing over to unit testStein Somers-31/+37
2020-08-14Auto merge of #74777 - ssomers:btree_cleanup_7, r=Mark-Simulacrumbors-20/+16
Stop BTreeMap casts from reborrowing Down in btree/node.rs, the interface and use of `cast_unchecked` look a bit shady. It's really just there for inverting `forget_type` which does not borrow. By borrowing we can't write the same `cast_unchecked` in the same way at the Handle level. No change in undefined behaviour or performance.
2020-08-14Update liballoc vec doc linkIvan Tham-8/+3
2020-08-14Update src/liballoc/vec.rsIvan Tham-1/+0
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-14Remove liballoc unneeded explicit linkIvan Tham-3/+0
2020-08-14add missing newlineDPC-1/+1
2020-08-14fix duplicated feature gateDPC-1/+0
2020-08-13Auto merge of #75105 - ssomers:btree_respect_min_len_hard, r=Mark-Simulacrumbors-16/+65
Hard way to respect BTreeMap's minimum node length Resolves #74834 the hard way (though not the hardest imaginable). Benchmarks (which are all biased/realistic, inserting keys in ascending order) say: ``` benchcmp r0 r1 --threshold 10 name r0 ns/iter r1 ns/iter diff ns/iter diff % speedup btree::map::clone_slim_100_and_clear 2,183 2,723 540 24.74% x 0.80 btree::map::clone_slim_100_and_drain_all 3,652 4,173 521 14.27% x 0.88 btree::map::clone_slim_100_and_drain_half 3,320 3,940 620 18.67% x 0.84 btree::map::clone_slim_100_and_into_iter 2,154 2,717 563 26.14% x 0.79 btree::map::clone_slim_100_and_pop_all 3,372 3,870 498 14.77% x 0.87 btree::map::clone_slim_100_and_remove_all 5,111 5,647 536 10.49% x 0.91 btree::map::clone_slim_100_and_remove_half 3,259 3,821 562 17.24% x 0.85 btree::map::iter_0 1,733 1,509 -224 -12.93% x 1.15 btree::map::iter_100 2,714 3,739 1,025 37.77% x 0.73 btree::map::iter_10k 3,728 4,269 541 14.51% x 0.87 btree::map::range_unbounded_unbounded 28,426 36,631 8,205 28.86% x 0.78 btree::map::range_unbounded_vs_iter 28,808 34,056 5,248 18.22% x 0.85 ``` This difference is not caused by the `debug_assert`-related code in the function `splitpoint`, it's the same without.
2020-08-13Reverts the fundamental changes in #74762 and #75257Stein Somers-49/+20
2020-08-13Stop BTreeMap casts from reborrowingStein Somers-20/+16
2020-08-13Add Arc::new_cyclicDPC-4/+148
2020-08-12Put panic code path from `copy_from_slice` into cold functionLukas Kalbertodt-2/+2
The previous `assert_eq` generated quite some code, which is especially problematic when this call is inlined. This commit also slightly improves the panic message from: assertion failed: `(left == right)` left: `3`, right: `2`: destination and source slices have different lengths ...to: source slice length (2) does not match destination slice length (3)
2020-08-12Rollup merge of #75424 - joseluis:patch-1, r=joshtriplettYuki Okushi-1/+1
fix wrong word in documentation Change "two" to "three", since there are three significantly different things printed below that sentence: --- While these: ```rust println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56); println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56"); println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56"); ``` print two significantly different things: ``` rust Hello, `1234.560` has 3 fractional digits Hello, `123` has 3 characters Hello, ` 123` has 3 right-aligned characters ``` --- [`https://doc.rust-lang.org/std/fmt/#precision`](https://doc.rust-lang.org/std/fmt/#precision)
2020-08-12Somewhat complicated way to respect BTreeMap's node length invariantStein Somers-16/+65
2020-08-11word changeJosé Luis Cruz-1/+1
there are three significantly different things printed below