Commit graph

142 commits

Author SHA1 Message Date
Surya Midatala
11f69796ee Move to intra-doc links for task.rs and vec.rs 2020-08-18 21:47:23 +05:30
Tim Diekmann
63d241a7b7 Make grow_impl unsafe 2020-08-18 15:22:10 +02:00
Stein Somers
8c4641b37f BTreeMap: check some invariants, avoid recursion in depth first search 2020-08-18 13:00:10 +02:00
Tim Diekmann
a9fe0ca47a Clean up AllocRef implementation and documentation 2020-08-18 09:53:22 +02:00
Tim Diekmann
c48f784418 Fix typo in comment 2020-08-17 15:05:19 +02:00
Tim Diekmann
c619b36975 Remove fast path in reallocation for same layout sizes 2020-08-17 13:23:38 +02:00
bors
f7aac25850 Auto merge of #75488 - ssomers:btree_revert_75257, r=Mark-Simulacrum
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-15 05:43:00 +00:00
DPC
9ad17b9ca7 tidy up 2020-08-15 03:16:20 +02:00
Tyler Mandry
939befd65e
Rollup merge of #75531 - ssomers:btree_tests_migration, r=Mark-Simulacrum
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-14 14:47:04 -07:00
Tyler Mandry
2564135115
Rollup merge of #75519 - ssomers:btree_splitpoint_cleanup, r=Mark-Simulacrum
BTreeMap: refactor splitpoint and move testing over to unit test

r? @Mark-Simulacrum
2020-08-14 14:47:01 -07:00
Tyler Mandry
83e75acdec
Rollup merge of #75195 - ssomers:btree_split_up_into_kv_mut, r=Mark-Simulacrum
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-14 14:46:45 -07:00
Tyler Mandry
3111a8c1e2
Rollup merge of #74185 - pickfire:liballoc-iter-doc, r=jyn514
Remove liballoc unneeded explicit link
2020-08-14 14:46:40 -07:00
Stein Somers
ff45df2acf Move btree unit test to their native, privileged location 2020-08-14 17:54:09 +02:00
Stein Somers
8d1c3c116b BTreeMap: refactor splitpoint and move testing over to unit test 2020-08-14 16:41:54 +02:00
Stein Somers
421e0ff3d9 BTreeMap: refactor splitpoint and move testing over to unit test 2020-08-14 14:50:30 +02:00
bors
7996182bc1 Auto merge of #74777 - ssomers:btree_cleanup_7, r=Mark-Simulacrum
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-14 12:00:59 +00:00
Ivan Tham
d2ecfcf21d Update liballoc vec doc link 2020-08-14 10:52:09 +08:00
Ivan Tham
e0d215ff9e Update src/liballoc/vec.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-14 10:50:30 +08:00
Ivan Tham
dba647ef32 Remove liballoc unneeded explicit link 2020-08-14 10:50:30 +08:00
DPC
fdc2d1f499 add missing newline 2020-08-14 01:28:04 +02:00
DPC
db34e352a7 fix duplicated feature gate 2020-08-14 01:05:43 +02:00
bors
81dc88f88f Auto merge of #75105 - ssomers:btree_respect_min_len_hard, r=Mark-Simulacrum
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-13 21:36:02 +00:00
Stein Somers
8668e5b29e Reverts the fundamental changes in #74762 and #75257 2020-08-13 16:29:56 +02:00
Stein Somers
0522040233 Stop BTreeMap casts from reborrowing 2020-08-13 09:42:55 +02:00
DPC
76b99d5f1d Add Arc::new_cyclic 2020-08-13 03:07:54 +02:00
Lukas Kalbertodt
db99f98c3e
Put panic code path from copy_from_slice into cold function
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-12 21:12:21 +02:00
Yuki Okushi
2cc7da6f95
Rollup merge of #75424 - joseluis:patch-1, r=joshtriplett
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-12 12:07:21 +09:00
Stein Somers
17ab457f21 Somewhat complicated way to respect BTreeMap's node length invariant 2020-08-12 00:09:00 +02:00
José Luis Cruz
df5c889784
word change
there are three significantly different things printed below
2020-08-11 22:33:11 +02:00
Ivan Tham
e4f2de2e9a
Fix range term in alloc vec doc
`range` is not an element, it is a variable.
2020-08-11 23:57:13 +08:00
Stein Somers
3a02e06002 BTreeMap: purge innocent use of into_kv_mut 2020-08-11 12:20:18 +02:00
Stein Somers
ef753fc6ed BTreeMap: better distinguish the root holder from the root node 2020-08-09 13:43:13 +02:00
Yuki Okushi
3370ac0042
Rollup merge of #75151 - pickfire:patch-4, r=LukasKalbertodt
Consistent variable name alloc for raw_vec
2020-08-09 06:41:18 +09:00
bors
1facd4a77b Auto merge of #75163 - canova:map_into_keys_values, r=dtolnay
Implement `into_keys` and `into_values` for associative maps

This PR implements `into_keys` and `into_values` for HashMap and BTreeMap types. They are implemented as unstable, under `map_into_keys_values` feature.
Fixes #55214.
r? @dtolnay
2020-08-08 18:15:50 +00:00
Nazım Can Altınova
4cd2637e2b
Update the tracking issue number of map_into_keys_values 2020-08-08 16:35:54 +02:00
Nazım Can Altınova
1cdce3919f
Remove min/max values from IntoValues Iterator implementation 2020-08-08 15:51:22 +02:00
bors
d19d7e2755 Auto merge of #75257 - ssomers:btree_74762_again, r=Mark-Simulacrum
BTreeMap: better way to postpone root access in DrainFilter

A slightly more elegant (in my opinion) adaptation of #74762. Benchmarks seem irrationally pleased to:
```
benchcmp old new --threshold 5
 name                                           old ns/iter  new ns/iter  diff ns/iter   diff %  speedup
 btree::map::clone_fat_100_and_remove_all       215,182      185,052           -30,130  -14.00%   x 1.16
 btree::map::clone_fat_100_and_remove_half      139,667      127,945           -11,722   -8.39%   x 1.09
 btree::map::clone_fat_val_100_and_remove_all   96,755       81,279            -15,476  -16.00%   x 1.19
 btree::map::clone_fat_val_100_and_remove_half  64,678       56,911             -7,767  -12.01%   x 1.14
 btree::map::find_rand_100                      18           17                     -1   -5.56%   x 1.06
 btree::map::first_and_last_0                   33           35                      2    6.06%   x 0.94
 btree::map::first_and_last_100                 40           54                     14   35.00%   x 0.74
 btree::map::insert_rand_100                    45           42                     -3   -6.67%   x 1.07
 btree::map::insert_rand_10_000                 45           41                     -4   -8.89%   x 1.10
 btree::map::iter_0                             2,010        1,759                -251  -12.49%   x 1.14
 btree::map::iter_100                           3,514        2,764                -750  -21.34%   x 1.27
 btree::map::iter_10k                           4,018        3,768                -250   -6.22%   x 1.07
 btree::map::range_unbounded_unbounded          37,269       28,929             -8,340  -22.38%   x 1.29
 btree::map::range_unbounded_vs_iter            31,518       28,814             -2,704   -8.58%   x 1.09
```

r? @Mark-Simulacrum
2020-08-08 07:46:04 +00:00
bors
c2d1b0d980 Auto merge of #75071 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
BTreeMap: enforce the panic rule imposed by `replace`

Also, reveal the unsafe parts in the closures fed to it.

r? @Mark-Simulacrum
2020-08-07 21:48:32 +00:00
Stein Somers
734fc0477c BTreeMap: enforce the panic rule imposed by replace 2020-08-07 19:51:26 +02:00
Stein Somers
85a7879341 BTreeMap: better way to postpone root access in DrainFilter 2020-08-07 15:02:56 +02:00
Nazım Can Altınova
16a5217141
Change the comment of BTreeMap::into_values 2020-08-07 14:10:12 +02:00
Nazım Can Altınova
29d9233cf6
Add unit tests for new BTreeMap::into_{keys,values} methods 2020-08-07 13:13:42 +02:00
Nazım Can Altınova
13529f22ba
Add into_{keys,values} methods for BTreeMap 2020-08-07 13:13:41 +02:00
Nazım Can Altınova
62e06a4d09
Make IntoIterator lifetime bounds of &BTreeMap match with &HashMap 2020-08-05 23:32:13 +02:00
Amos Onn
ab204c5b20 Add {Box,Rc,Arc}::new_zeroed_slice 2020-08-05 08:32:10 +02:00
Amos Onn
361f668c49 Use alloc_zeroed in {Rc,Arc}::new_zeroed 2020-08-05 08:32:05 +02:00
Tim Diekmann
ab9362ad9a Replace Memoryblock with NonNull<[u8]> 2020-08-04 18:03:34 +02:00
Ivan Tham
e1ef3fa686
Consistent variable name alloc for raw_vec 2020-08-04 23:46:14 +08:00
bors
5f6bd6ec0a Auto merge of #74850 - TimDiekmann:remove-in-place-alloc, r=Amanieu
Remove in-place allocation and revert to separate methods for zeroed allocations

closes rust-lang/wg-allocators#58
2020-08-04 11:22:45 +00:00
bors
80f84eb9c6 Auto merge of #75058 - ssomers:btree_cleanup_insert_2, r=Mark-Simulacrum
Clarify reuse of a BTreeMap insert support function and treat split support likewise

r? @Mark-Simulacrum
2020-08-04 03:48:48 +00:00
bors
829d69b9c6 Auto merge of #74827 - ssomers:btree_cleanup_insert, r=Mark-Simulacrum
Move bulk of BTreeMap::insert method down to new method on handle

Adjust the boundary between the map and node layers for insertion: do more in the node layer, keep root manipulation and pointer dereferencing separate. No change in undefined behaviour or performance.

r? @Mark-Simulacrum
2020-08-03 15:46:02 +00:00
Tim Diekmann
24ddf76ed7
Merge branch 'master' into remove-in-place-alloc 2020-08-03 02:18:20 +02:00
Manish Goregaokar
9471ab068c
Rollup merge of #75059 - shengsheng:typos, r=Dylan-DPC
fix typos

Fix common misspellings with https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-08-02 13:08:47 -07:00
Stein Somers
532e7f49fc Separate off a leafy insert function instead of lying, and split split similarly 2020-08-02 21:42:17 +02:00
Stein Somers
f5c47fa44d Move bulk of BTreeMap::insert method down to new method on handle 2020-08-02 20:20:42 +02:00
Yuki Okushi
7d18040b0c
Rollup merge of #74974 - RalfJung:miri-tests, r=Mark-Simulacrum
Make tests faster in Miri

Reduce some test iteration counts in Miri.
2020-08-03 01:05:20 +09:00
Yuki Okushi
1033c74665
Rollup merge of #74874 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
BTreeMap: define forget_type only when relevant

Similar to `forget_node_type` for handles.
No effect on generated code, apart maybe from the superfluous calls that might not have been optimized away.

r? @Mark-Simulacrum
2020-08-03 01:05:18 +09:00
Yuki Okushi
814b31eb2e
Rollup merge of #74762 - ssomers:btree_no_root_in_remove_kv_tracking, r=Mark-Simulacrum
BTreeMap::drain_filter should not touch the root during iteration

Although Miri doesn't point it out, I believe there is undefined behaviour using `drain_filter` when draining the 11th-last element from a tree that was larger. When this happens, the last remaining child nodes are merged, the root becomes empty and is popped from the tree. That last step establishes a mutable reference to the node elected root and writes a pointer in `node::Root`, while iteration continues to visit the same node.

This is mostly code from #74437, slightly adapted.
2020-08-03 01:05:13 +09:00
Yuki Okushi
8c331ee470
Rollup merge of #74686 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
BTreeMap: remove into_slices and its unsafe block

A small tweak to make BTreeMap code shorter and less unsafe.

r? @Mark-Simulacrum
2020-08-03 01:05:12 +09:00
liuzhenyu
3b4151c9f3 fix typos 2020-08-02 23:20:00 +08:00
bors
e18b56345f Auto merge of #75033 - Manishearth:rollup-d8afil1, r=Manishearth
Rollup of 5 pull requests

Successful merges:

 - #74602 (Clarify the doc for MaybeUninit::zeroed on incorrect use)
 - #74720 (Clean up E0728 explanation)
 - #74992 (fix rustdoc generic param order)
 - #75015 (Add Vec::spare_capacity_mut)
 - #75022 (Use a slice pattern instead of rchunks_exact(_).next())

Failed merges:

r? @ghost
2020-08-02 01:04:54 +00:00
bors
5ef872f961 Auto merge of #74605 - rust-lang:vec-leak, r=Amanieu
Stabilize Vec::leak as a method

Closes https://github.com/rust-lang/rust/issues/62195

The signature is changed to a method rather than an associated function:

```diff
-pub fn leak<'a>(vec: Vec<T>) -> &'a mut [T]
+pub fn leak<'a>(self) -> &'a mut [T]
```

The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T` which might have its own, different `leak` method) does not apply.
2020-08-01 22:29:30 +00:00
Stein Somers
99398dd2fd BTreeMap::drain_filter no longer touches the root during iteration 2020-08-01 23:35:30 +02:00
Stein Somers
602f9aab89 More benchmarks of BTreeMap mutation 2020-08-01 20:23:13 +02:00
Amanieu d'Antras
df3a30aee4 Add Vec::spare_capacity_mut 2020-08-01 18:24:35 +01:00
Stein Somers
240ef70c7b Define forget_type only when relevant 2020-08-01 14:09:19 +02:00
bors
b5eae9c44d Auto merge of #74373 - lcnr:array_chunks, r=withoutboats
add `slice::array_chunks` to std

Now that #74113 has landed, these methods are suddenly usable. A rebirth of #72334

Tests are directly copied from `chunks_exact` and some additional tests for type inference.

r? @withoutboats as you are both part of t-libs and working on const generics. closes #60735
2020-08-01 06:54:14 +00:00
Bastian Kauschke
d51b71a35a add tracking issue 2020-08-01 07:49:24 +02:00
Yuki Okushi
ab4570eaf0
Rollup merge of #74644 - crlf0710:drop_old_stuff, r=Amanieu
Remove `linked_list_extras` methods.

Removing these in favor of the `Cursor` API in https://github.com/rust-lang/rust/issues/58533 .
Closes #27794.

r? @Amanieu
2020-08-01 08:02:04 +09:00
Charles Lew
dc21178830 Remove linked_list_extras methods. 2020-08-01 00:54:22 +08:00
Ralf Jung
ff0c3a9209 expand comments 2020-07-31 14:03:42 +02:00
Ralf Jung
7e168a696f reduce slice::panic_safe test size further in Miri 2020-07-31 11:56:08 +02:00
Ralf Jung
0a62b7dc92 make some vec_deque tests less exhaustive in Miri 2020-07-31 11:56:08 +02:00
bors
ffa80f01d8 Auto merge of #74926 - Manishearth:rename-lint, r=jyn514
Rename intra_doc_link_resolution_failure

It should be plural to follow the conventions in https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints
2020-07-31 02:20:47 +00:00
Manish Goregaokar
46379687ac
Rollup merge of #74782 - vorner:weak-into-raw-cnt-doc, r=dtolnay
Don't use "weak count" around Weak::from_raw_ptr

As `Rc/Arc::weak_count` returns 0 when having no strong counts, this
could be confusing and it's better to avoid using that completely.

Closes #73840.
2020-07-30 13:04:29 -07:00
Manish Goregaokar
522ef2e981 Remove deny for intra doc link failures from library code, it's no longer necessary 2020-07-30 08:14:27 -07:00
Manish Goregaokar
7b7b5a7a12 Rename in library 2020-07-30 08:14:27 -07:00
Bastian Kauschke
95fa63e63f liballoc export ArrayChunks 2020-07-30 10:50:35 +02:00
Manish Goregaokar
0f9b7bd80f
Rollup merge of #74902 - rust-lang:into_raw_non_null, r=dtolnay
Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions

FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613
2020-07-29 16:38:28 -07:00
Manish Goregaokar
c07998e0e7
Rollup merge of #74852 - lzutao:inline-rm-tostring, r=nnethercote
Explain why inlining default ToString impl

Trying to remove inline attribute from default ToString impl causes regression.
Perf result at <https://github.com/rust-lang/rust/pull/74852#issuecomment-664812994>.
2020-07-29 16:38:22 -07:00
Tim Diekmann
b01fbc437e Simplify implementations of AllocRef for Global and System 2020-07-29 11:41:36 +02:00
Simon Sapin
1fb67363bf Remove deprecated unstable {Box,Rc,Arc}::into_raw_non_null functions
FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613
2020-07-29 11:00:31 +02:00
Simon Sapin
7d759f539f Stabilize Vec::leak 2020-07-29 10:53:55 +02:00
Simon Sapin
d8bcf75206 Make Vec::leak a method instead of an associated function.
The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T`
which might have its own, different `leak` method) does not apply.
2020-07-29 10:53:55 +02:00
Tomasz Miąsko
1b4a6a5183 Link to syntax section when referencing it 2020-07-29 10:43:40 +02:00
Lzu Tao
27e1b0632c Explain why inline default ToString impl 2020-07-29 07:38:06 +00:00
Stein Somers
c4f4639e1a Remove into_slices and its unsafe block 2020-07-28 15:21:27 +02:00
Jon Gjengset
2f96ce89d0
Stabilize deque_make_contiguous
Closes #70929.
2020-07-28 08:36:54 -04:00
Tim Diekmann
076ef66ba2 Remove in-place allocation and revert to separate methods for zeroed allocations
Fix docs
2020-07-28 12:41:18 +02:00
Aleksey Kladov
6e9dc7d9ff Add str::[r]split_once
This is useful for quick&dirty parsing of key: value config pairs
2020-07-28 09:58:20 +02:00
Michal 'vorner' Vaner
ad6d63ef01
Don't use "weak count" around Weak::from_raw_ptr
As `Rc/Arc::weak_count` returns 0 when having no strong counts, this
could be confusing and it's better to avoid using that completely.

Closes #73840.
2020-07-28 08:30:32 +02:00
mark
2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00