Commit graph

606 commits

Author SHA1 Message Date
Dylan DPC
bfa854dbe5
Rollup merge of #79363 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum
BTreeMap: try to enhance various comments

All in internal documentation, propagating the "key-value pair" notation from public documentation.

r? ``@Mark-Simulacrum``
2020-11-29 03:14:15 +01:00
Dylan DPC
a2b4d97984
Rollup merge of #79327 - TimDiekmann:static-alloc-pin-in-box, r=Mark-Simulacrum
Require allocator to be static for boxed `Pin`-API

Allocators has to retain their validity until the instance and all of its clones are dropped. When pinning a value, it must live forever, thus, the allocator requires a `'static` lifetime for pinning a value. [Example from reddit](https://www.reddit.com/r/rust/comments/jymzdw/the_story_continues_vec_now_supports_custom/gd7qak2?utm_source=share&utm_medium=web2x&context=3):

```rust
let alloc = MyAlloc(/* ... */);
let pinned = Box::pin_in(42, alloc);
mem::forget(pinned); // Now `value` must live forever
// Otherwise `Pin`'s invariants are violated, storage invalidated
// before Drop was called.
// borrow of `memory` can end here, there is no value keeping it.
drop(alloc); // Oh, value doesn't live forever.
```
2020-11-29 03:14:07 +01:00
Tim Diekmann
7387f48e50 Require allocator to be static for boxed Pin-API 2020-11-28 15:24:44 +01:00
Stein Somers
d1a2c0f99c BTreeMap: try to enhance various comments & local identifiers 2020-11-28 10:35:02 +01:00
Aaron Hill
6f91c32da6
Fix new 'unnecessary trailing semicolon' warnings 2020-11-26 17:08:36 -05:00
bors
ec039bd075 Auto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obk
Rename `optin_builtin_traits` to `auto_traits`

They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.

r? `@oli-obk` (feel free to re-assign if you're not the right reviewer for this)
2020-11-25 07:25:19 +00:00
Jonas Schievink
ce197961ac
Rollup merge of #79358 - ssomers:btree_public_comments, r=Mark-Simulacrum
BTreeMap/BTreeSet: make public doc more consistent

Tweaks #72876 and #73667 and propagate them to `BTreeSet`.
2020-11-24 13:17:47 +01:00
Jonas Schievink
012d5fd8d7
Rollup merge of #79354 - ssomers:btree_bereave_BoxedNode, r=Mark-Simulacrum
BTreeMap: cut out the ceremony around BoxedNode

The opposite direction of #79093.

r? ``@Mark-Simulacrum``
2020-11-24 13:17:45 +01:00
Camelid
810324d1f3 Rename optin_builtin_traits to auto_traits
They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
2020-11-23 14:14:06 -08:00
Stein Somers
9c8db454af BTreeMap/BTreeSet: make public doc more consistent 2020-11-23 19:10:02 +01:00
bors
40624dde6c Auto merge of #79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievink
Rollup of 10 pull requests

Successful merges:

 - #76829 (stabilize const_int_pow)
 - #79080 (MIR visitor: Don't treat debuginfo field access as a use of the struct)
 - #79236 (const_generics: assert resolve hack causes an error)
 - #79287 (Allow using generic trait methods in `const fn`)
 - #79324 (Use Option::and_then instead of open-coding it)
 - #79325 (Reduce boilerplate with the `?` operator)
 - #79330 (Fix typo in comment)
 - #79333 (doc typo)
 - #79337 (Use Option::map instead of open coding it)
 - #79343 (Add my (`@flip1995)` work mail to the mailmap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-23 16:33:03 +00:00
Stein Somers
8526c313c1 BTreeMap: cut out the ceremony around BoxedNode 2020-11-23 17:02:08 +01:00
Jonas Schievink
a0cf162329
Rollup merge of #79333 - o752d:patch-3, r=Mark-Simulacrum
doc typo

plus a small edit for clarity
2020-11-23 15:25:51 +01:00
bors
40cf72108e Auto merge of #79186 - JulianKnodt:str_from, r=Mark-Simulacrum
Change slice::to_vec to not use extend_from_slice

I saw this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/String.3A.3Afrom%28.26str%29.20wonky.20codegen/near/216164455), and didn't see any update from it, so I thought I'd try to fix it. This converts `to_vec` to no longer use `extend_from_slice`, but relies on knowing that the allocated capacity is the same size as the input.

[Godbolt new v1](https://rust.godbolt.org/z/1bcWKG)
[Godbolt new v2 w/ drop guard](https://rust.godbolt.org/z/5jn76K)
[Godbolt old version](https://rust.godbolt.org/z/e4ePav)

After some amount of iteration, there are now two specializations for `to_vec`, one for `Copy` types that use memcpy, and one for clone types which is the original from this PR.

This is then used inside of `impl<T: Clone> FromIterator<Iter::Slice<T>> for Vec<T>` which is essentially equivalent to `&[T] -> Vec<T>`, instead of previous specialization of the `extend` function. This is because extend has to reason more about existing capacity by calling `reserve` on an existing vec, and thus produces worse asm.

Downsides: This allocates the exact capacity, so I think if many items are added to this `Vec` after, it might need to allocate whereas extending may not. I also noticed the number of faults went up in the benchmarks, but not sure where from exactly.
2020-11-23 14:20:22 +00:00
oliver
a804e38dde
doc typo
plus a small edit for clarity
2020-11-23 02:47:45 +00:00
bors
f32459c7ba Auto merge of #79172 - a1phyr:cold_abort, r=Mark-Simulacrum
Add #[cold] attribute to `std::process::abort` and `alloc::alloc::handle_alloc_error`
2020-11-23 02:25:13 +00:00
bors
32da90b431 Auto merge of #79319 - m-ou-se:rollup-d9n5viq, r=m-ou-se
Rollup of 10 pull requests

Successful merges:

 - #76941 (Add f{32,64}::is_subnormal)
 - #77697 (Split each iterator adapter and source into individual modules)
 - #78305 (Stabilize alloc::Layout const functions)
 - #78608 (Stabilize refcell_take)
 - #78793 (Clean up `StructuralEq` docs)
 - #79267 (BTreeMap: address namespace conflicts)
 - #79293 (Add test for eval order for a+=b)
 - #79295 (BTreeMap: fix minor testing mistakes in #78903)
 - #79297 (BTreeMap: swap the names of NodeRef::new and Root::new_leaf)
 - #79299 (Stabilise `then`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-22 23:59:48 +00:00
kadmin
a9915581d7 Change slice::to_vec to not use extend_from_slice
This also required adding a loop guard in case clone panics

Add specialization for copy

There is a better version for copy, so I've added specialization for that function
and hopefully that should speed it up even more.

Switch FromIter<slice::Iter> to use `to_vec`

Test different unrolling version for to_vec

Revert to impl

From benchmarking, it appears this version is faster
2020-11-22 22:22:03 +00:00
Mara Bos
d39e095331
Rollup merge of #79297 - ssomers:btree_post_redux, r=Mark-Simulacrum
BTreeMap: swap the names of NodeRef::new and Root::new_leaf

#78104 preserved the name of Root::new_leaf to minimize changes, but the resulting names are confusing.

r? `@Mark-Simulacrum`
2020-11-22 23:01:07 +01:00
Mara Bos
b54838f960
Rollup merge of #79295 - ssomers:btree_fix_78903, r=Mark-Simulacrum
BTreeMap: fix minor testing mistakes in #78903

Mostly a duplicate test case
r? `@Mark-Simulacrum`
2020-11-22 23:01:05 +01:00
Mara Bos
5793fa9cda
Rollup merge of #79267 - ssomers:btree_namespaces, r=Mark-Simulacrum
BTreeMap: address namespace conflicts

Fix an annoyance popping up whenever synchronizing the test cases with a version capable of miri-track-raw-pointers.

r? `@Mark-Simulacrum`
2020-11-22 23:01:02 +01:00
bors
a0d664bae6 Auto merge of #79219 - shepmaster:beta-bump, r=Mark-Simulacrum
Bump bootstrap compiler version

r? `@Mark-Simulacrum`

/cc `@pietroalbini`
2020-11-22 21:38:03 +00:00
Stein Somers
b04abc433e BTreeMap: swap the names of NodeRef::new and Root::new_leaf 2020-11-22 13:40:03 +01:00
Stein Somers
9186c073fc BTreeMap: fix minor testing mistakes in #78903 2020-11-22 13:37:39 +01:00
bors
20328b5323 Auto merge of #79275 - integer32llc:doc-style, r=jonas-schievink
More consistently use spaces after commas in lists in docs

This PR changes instances of lists that didn't use spaces after commas, like `vec![1,2,3]`, to `vec![1, 2, 3]` to be more consistent with idiomatic Rust style (the way these were looks strange to me, especially because there are often lists that *do* use spaces after the commas later in the same code block 😬).

I noticed one of these in an example in the stdlib docs and went looking for more, but as far as I can see, I'm only changing those spots in user-facing documentation or rustc output, and the changes make no semantic difference.
2020-11-22 08:30:23 +00:00
bors
a1a13b2bc4 Auto merge of #78461 - TimDiekmann:vec-alloc, r=Amanieu
Add support for custom allocators in `Vec`

This follows the [roadmap](https://github.com/rust-lang/wg-allocators/issues/7) of the allocator WG to add custom allocators to collections.

r? `@Amanieu`

This pull request requires a crater run.

### Prior work:
- #71873: Crater-test to solve rust-lang/wg-allocators#1
- [`alloc-wg`](https://github.com/TimDiekmann/alloc-wg)-crate
2020-11-21 22:46:50 +00:00
Carol (Nichols || Goulding)
ae17d7d455
More consistently use spaces after commas in lists in docs 2020-11-21 14:43:34 -05:00
Dylan DPC
6cd02a85f1
Rollup merge of #77844 - RalfJung:zst-box, r=nikomatsakis
clarify rules for ZST Boxes

LLVM's rules around `getelementptr inbounds` with offset 0 are a bit annoying, and as a consequence we have no choice but say that a `Box<()>` pointing to previously allocated memory that has since been freed is UB. Clarify the docs to reflect this.

This is based on conversations on the LLVM mailing list.
* Here's my initial mail: https://lists.llvm.org/pipermail/llvm-dev/2019-February/130452.html
* The first email of the March part of that thread: https://lists.llvm.org/pipermail/llvm-dev/2019-March/130831.html
* First email of the April part: https://lists.llvm.org/pipermail/llvm-dev/2019-April/131693.html

The conclusion for me at least was that `getelementptr inbounds` with offset 0 is *not* the identity function, but can sometimes return `poison` even when the input is a regular pointer -- specifically, it returns `poison` when this pointer points into something that LLVM "knows has been deallocated", i.e., a former LLVM-managed allocation. It is however the identity function on pointers obtained by casting integers.

Note that there [are formal proposals](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf) for LLVM semantics where `getelementptr inbounds` with offset 0 isn't quite the identity function but never returns `poison` (it affects the provenance of the pointer but in a way that doesn't matter if this pointer is never used for memory accesses), and indeed this is likely necessary to consistently describe LLVM semantics. But with the informal LLVM LangRef that we have right now, and with LLVM devs insisting otherwise, it seems unwise to rely on this.
2020-11-21 19:44:07 +01:00
Stein Somers
0f005c2241 BTreeMap: address namespace conflicts 2020-11-21 16:07:24 +01:00
Ralf Jung
a7677f7714 reference NonNull::dangling 2020-11-20 11:09:49 +01:00
Jake Goulding
dcef5ff372 Bump bootstrap compiler version 2020-11-19 19:23:36 -05:00
Tim Diekmann
8725e4c337 Add support for custom allocators in Vec 2020-11-18 19:34:19 +01:00
Benoît du Garreau
b4c91f9a52 Add #[cold] to abort and handle_alloc_error 2020-11-18 18:15:03 +01:00
Stein Somers
9fca57ceb9 BTreeMap: reuse NodeRef as Root, keep BoxedNode for edges only, ban Unique 2020-11-18 10:07:42 +01:00
Mara Bos
70a4e433b1
Rollup merge of #79077 - RalfJung:llvm-magic, r=Mark-Simulacrum
document that __rust_alloc is also magic to our LLVM fork

Based on [comments](https://github.com/rust-lang/rust/pull/79045#discussion_r523442198) by ````@tmiasko```` and ````@bjorn3.````
2020-11-17 10:06:23 +01:00
Mara Bos
bac213bee4
Rollup merge of #78903 - ssomers:btree_order_chaos_testing, r=Mark-Simulacrum
BTreeMap: test chaotic ordering & other bits & bobs

r? `@Mark-Simulacrum`
2020-11-16 17:26:33 +01:00
Mara Bos
5bbf75da78
Rollup merge of #77691 - exrook:rename-layouterr, r=KodrAus
Rename/Deprecate LayoutErr in favor of LayoutError

Implements rust-lang/wg-allocators#73.

This patch renames LayoutErr to LayoutError, and uses a type alias to support users using the old name.

The new name will be instantly stable in release 1.49 (current nightly), the type alias will become deprecated in release 1.51 (so that when the current nightly is 1.51, 1.49 will be stable).

This is the only error type in `std` that ends in `Err` rather than `Error`, if this PR lands all stdlib error types will end in `Error` 🥰
2020-11-16 17:26:17 +01:00
bors
f5230fbf76 Auto merge of #78631 - ssomers:btree-alias_for_underfull, r=Mark-Simulacrum
BTreeMap: fix pointer provenance rules in underfullness

Continuing on #78480, and for readability, and possibly for performance: avoid aliasing when handling underfull nodes, and consolidate the code doing that. In particular:
- Avoid the rather explicit aliasing for internal nodes in `remove_kv_tracking`.
- Climb down to the root to handle underfull nodes using a reborrowed handle, rather than one copied with `ptr::read`, before resuming on the leaf level.
- Integrate the code tracking leaf edge position into the functions performing changes, rather than bolting it on.

r? `@Mark-Simulacrum`
2020-11-16 03:22:10 +00:00
Ralf Jung
af869c2f8d document that __rust_alloc is also magic to our LLVM fork 2020-11-15 18:40:49 +01:00
bors
5fab31e5dd Auto merge of #79070 - jonas-schievink:rollup-wacn2b8, r=jonas-schievink
Rollup of 13 pull requests

Successful merges:

 - #77802 (Allow making `RUSTC_BOOTSTRAP` conditional on the crate name)
 - #79004 (Add `--color` support to bootstrap)
 - #79005 (cleanup: Remove `ParseSess::injected_crate_name`)
 - #79016 (Make `_` an expression, to discard values in destructuring assignments)
 - #79019 (astconv: extract closures into a separate trait)
 - #79026 (Implement BTreeMap::retain and BTreeSet::retain)
 - #79031 (Validate that locals have a corresponding `LocalDecl`)
 - #79034 (rustc_resolve: Make `macro_rules` scope chain compression lazy)
 - #79036 (Move Steal to rustc_data_structures.)
 - #79041 (Rename clean::{ItemEnum -> ItemKind}, clean::Item::{inner -> kind})
 - #79058 (Move likely/unlikely argument outside of invisible unsafe block)
 - #79059 (Print 'checking cranelift artifacts' to easily separate it from other artifacts)
 - #79063 (Update rustfmt to v1.4.26)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-15 13:19:05 +00:00
Jonas Schievink
aa685e2024
Rollup merge of #79026 - mbrubeck:btree_retain, r=m-ou-se
Implement BTreeMap::retain and BTreeSet::retain

Adds new methods `BTreeMap::retain` and `BTreeSet::retain`.  These are implemented on top of `drain_filter` (#70530).

The API of these methods is identical to `HashMap::retain` and `HashSet::retain`, which were implemented in #39560 and stabilized in #36648.  The docs and tests are also copied from HashMap/HashSet.

The new methods are unstable, behind the `btree_retain` feature gate, with tracking issue #79025.  See also rust-lang/rfcs#1338.
2020-11-15 13:39:54 +01:00
Spyros Roum
161300d41e stabilize deque_range 2020-11-15 13:30:35 +02:00
bors
0468845924 Auto merge of #78472 - hermitcore:builtins, r=Mark-Simulacrum
add options to use optimized and mangled compiler builtins

In principle the compiler builtin features are also offered to alloc and std.
2020-11-15 10:37:11 +00:00
Stefan Lankes
6de51252e0
add options to use optimized and mangled compiler builtins 2020-11-15 08:23:31 +01:00
Matt Brubeck
bf6902ca61 Add BTreeMap::retain and BTreeSet::retain 2020-11-13 10:23:50 -08:00
C
75dfc711da refactor: vec_deque ignore-tidy-filelength
commit c547d5fabcd756515afa7263ee5304965bb4c497
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 11:22:23 2020 +0000

    test: updating ui/hygiene/panic-location.rs expected

commit 2af03769c4ffdbbbad75197a1ad0df8c599186be
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 10:43:30 2020 +0000

    fix: documentation unresolved link

commit c4b0df361ce27d7392d8016229f2e0265af32086
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 02:58:31 2020 +0000

    style: compiling with Rust's style guidelines

commit bdd2de5f3c09b49a18e3293f2457fcab25557c96
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 02:56:31 2020 +0000

    refactor: removing ignore-tidy-filelength

commit fcc4b3bc41f57244c65ebb8e4efe4cbc9460b5a9
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 02:51:35 2020 +0000

    refactor: moving trait RingSlices to ring_slices.rs

commit 2f0cc539c06d8841baf7f675168f68ca7c21e68e
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 02:46:09 2020 +0000

    refactor: moving struct PairSlices to pair_slices.rs

commit a55d3ef1dab4c3d85962b3a601ff8d1f7497faf2
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 02:31:45 2020 +0000

    refactor: moving struct Iter to iter.rs

commit 76ab33a12442a03726f36f606b4e0fe70f8f246b
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 02:24:32 2020 +0000

    refactor: moving struct IntoIter into into_iter.rs

commit abe0d9eea2933881858c3b1bc09df67cedc5ada5
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 02:19:07 2020 +0000

    refactor: moving struct IterMut into iter_mut.rs

commit 70ebd6420335e1895e2afa2763a0148897963e24
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 01:49:15 2020 +0000

    refactor: moved macros into macros.rs

commit b08dd2add994b04ae851aa065800bd8bd6326134
Author: C <DeveloperC@protonmail.com>
Date:   Sat Oct 31 01:05:36 2020 +0000

    refactor: moving vec_deque.rs to vec_deque/mod.rs
2020-11-13 17:56:39 +00:00
Mara Bos
40889819ee
Rollup merge of #78857 - SkiFire13:bheap-opt, r=KodrAus
Improve BinaryHeap performance

By changing the condition in the loops from `child < end` to `child < end - 1` we're guaranteed that `right = child + 1 < end` and since finding the index of the biggest sibling can be done with an arithmetic operation we can remove a branch from the loop body. The case where there's no right child, i.e. `child == end - 1` is instead handled outside the loop, after it ends; note that if the loops ends early we can use `return` instead of `break` since the check `child == end - 1` will surely fail.

I've also removed a call to `<[T]>::swap` that was hiding a bound check that [wasn't being optimized by LLVM](https://godbolt.org/z/zrhdGM).

A quick benchmarks on my pc shows that the gains are pretty significant:

|name                 |before ns/iter  |after ns/iter  |diff ns/iter  |diff %    |speedup |
|---------------------|----------------|---------------|--------------|----------|--------|
|find_smallest_1000   | 352,565        | 260,098       |     -92,467  | -26.23%  | x 1.36 |
|from_vec             | 676,795        | 473,934       |    -202,861  | -29.97%  | x 1.43 |
|into_sorted_vec      | 469,511        | 304,275       |    -165,236  | -35.19%  | x 1.54 |
|pop                  | 483,198        | 373,778       |    -109,420  | -22.64%  | x 1.29 |

The other 2 benchmarks for `BinaryHeap` (`peek_mut_deref_mut` and `push`) weren't impacted and as such didn't show any significant change.
2020-11-12 19:46:11 +01:00
Stein Somers
8972bcb0dd BTreeMap: test chaotic ordering & other bits & bobs 2020-11-12 16:18:30 +01:00
Stein Somers
4cfa5bddf1 BTreeMap: avoid aliasing while handling underfull nodes 2020-11-12 10:09:59 +01:00
Jonas Schievink
56e0806a1a
Rollup merge of #78417 - ssomers:btree_chop_up_2, r=Mark-Simulacrum
BTreeMap: split off most code of append

To complete #78056, move the last single-purpose pieces of code out of map.rs into a separate module. Also, tweaked documentation and safeness - I doubt think this code would be safe if the iterators passed in wouldn't be as sorted as the method says they should be - and bounds on MergeIterInner.

r? ```@Mark-Simulacrum```
2020-11-11 20:59:00 +01:00
Jonas Schievink
e15fee9fe4
Rollup merge of #78854 - the8472:workaround-normalization-regression-master, r=Mark-Simulacrum
Workaround for "could not fully normalize" ICE

Workaround for "could not fully normalize" ICE (#78139) by removing the `needs_drop::<T>()` calls triggering it.
Corresponding beta PR: #78845

Fixes #78139 -- the underlying bug is likely not fixed but we don't have another test case isolated for now, so closing.
2020-11-10 14:45:19 +01:00
Giacomo Stevanato
387568cd56 Added SAFETY comment as request 2020-11-09 22:34:31 +01:00
Stein Somers
7ca6e8f767 BTreeMap: fix pointer provenance rules, make borrowing explicit 2020-11-09 09:13:50 +01:00
Dylan DPC
5639d9793f
Rollup merge of #78476 - RalfJung:btree-alias, r=Mark-Simulacrum
fix some incorrect aliasing in the BTree

This line is wrong:
```
ptr::copy(slice.as_ptr().add(idx), slice.as_mut_ptr().add(idx + 1), slice.len() - idx);
```
When `slice.as_mut_ptr()` is called, that creates a mutable reference to the entire slice, which invalidates the raw pointer previously returned by `slice.as_ptr()`. (Miri currently misses this because raw pointers are not tracked properly.)

Cc ````````@ssomers````````
2020-11-09 01:13:40 +01:00
Dylan DPC
4e5b7add7f
Rollup merge of #78437 - ssomers:btree_no_ord_at_node_level, r=Mark-Simulacrum
BTreeMap: stop mistaking node for an orderly place

A second mistake in #77612 was to ignore the node module's rightful comment "this module doesn't care whether the entries are sorted". And there's a much simpler way to visit the keys in order, if you check this separately from a single pass checking everything.

r? ````````@Mark-Simulacrum````````
2020-11-09 01:13:38 +01:00
Stein Somers
685fd53ada BTreeMap: split off most code of append, slightly improve interfaces 2020-11-08 18:58:46 +01:00
Mara Bos
96975e515a
Rollup merge of #78852 - camelid:intra-doc-bonanza, r=jyn514
Convert a bunch of intra-doc links

An intra-doc link bonanza!

This was accomplished using a bunch of trial-and-error with sed.
2020-11-08 13:36:28 +01:00
Mara Bos
1f034f77bc
Rollup merge of #76097 - pickfire:stabilize-spin-loop, r=KodrAus
Stabilize hint::spin_loop

Partially fix #55002, deprecate in another release

r? ``````@KodrAus``````
2020-11-08 13:35:54 +01:00
Giacomo Stevanato
8d1575365d Remove useless bound checks from into_sorted_vec 2020-11-07 22:20:26 +01:00
Giacomo Stevanato
25b3f61c38 Remove useless branches from sift_down_range loop 2020-11-07 22:20:26 +01:00
Giacomo Stevanato
6dfcf9afde Remove branches from sift_down_to_bottom loop 2020-11-07 22:20:26 +01:00
Camelid
8258cf285f Convert a bunch of intra-doc links 2020-11-07 12:50:57 -08:00
The8472
8c7046e675 remove needs_drop 2020-11-07 21:40:55 +01:00
Yuki Okushi
162f400328
Rollup merge of #78538 - ssomers:btree_testing_rng, r=Mark-Simulacrum
BTreeMap: document a curious assumption in test cases

r? ```@Mark-Simulacrum```
2020-11-07 01:02:09 +09:00
Ivan Tham
e8b5be5dff Stabilize hint::spin_loop
Partially fix #55002, deprecate in another release

Co-authored-by: Ashley Mannix <kodraus@hey.com>

Update stable version for stabilize_spin_loop

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Use better example for spinlock

As suggested by KodrAus

Remove renamed_spin_loop already available in master

Fix spin loop example
2020-11-06 23:41:55 +08:00
Mara Bos
55f4b802fb
Rollup merge of #76718 - poliorcetics:vec-ui-to-unit-test, r=jyn514
Move Vec UI tests to unit tests when possible

Helps with #76268.

I'm moving the tests using `Vec` or `VecDeque`.

````@rustbot```` modify labels: A-testsuite C-cleanup T-libs
2020-11-05 10:29:35 +01:00
Mara Bos
8ed31d2782
Rollup merge of #78602 - RalfJung:raw-ptr-aliasing-issues, r=m-ou-se
fix various aliasing issues in the standard library

This fixes various cases where the standard library either used raw pointers after they were already invalidated by using the original reference again, or created raw pointers for one element of a slice and used it to access neighboring elements.
2020-11-01 11:53:36 +01:00
Mara Bos
25eac92987
Rollup merge of #78596 - pavlukivan:master, r=m-ou-se
Fix doc links to std::fmt

`std::format` and `core::write` macros' docs linked to `core::fmt` for format string reference, even though only `std::fmt` has format string documentation (and the link titles were `std::fmt`)
2020-11-01 11:53:33 +01:00
Ralf Jung
607076e209 fix aliasing issue in binary_heap 2020-10-31 16:26:06 +01:00
Ivan Pavluk
3baf6a4a74 Fix doc links to std::fmt
std::format and core::write macros' docs linked to core::fmt for format string reference, even though only std::fmt has format string documentation and the link titles were std::fmt.
2020-10-31 18:02:55 +07:00
Benoît du Garreau
307cc11beb Constantify more BTreeMap and BTreeSet functions
- BTreeMap::len
- BTreeMap::is_empty
- BTreeSet::len
- BTreeSet::is_empty
2020-10-30 19:24:08 +01:00
Yuki Okushi
0723b274d2
Rollup merge of #77334 - pickfire:patch-4, r=jyn514
Reorder benches const variable

Move LEN so it is is read in order.
2020-10-30 18:00:41 +09:00
Stein Somers
be01d54f07 BTreeMap: document a curious assumption in test cases 2020-10-29 20:51:39 +01:00
Jonas Schievink
48c4afbf9c
Rollup merge of #78499 - SkiFire13:fix-string-retain, r=m-ou-se
Prevent String::retain from creating non-utf8 strings when abusing panic

Fixes #78498

The idea is the same as `Vec::drain`, set the len to 0 so that nobody can observe the broken invariant if it escapes the function (in this case if `f` panics)
2020-10-29 17:05:28 +01:00
Jonas Schievink
a384a5866b
Rollup merge of #76138 - camelid:rc-fully-qualified-syntax, r=steveklabnik
Explain fully qualified syntax for `Rc` and `Arc`

Also cleaned up some other small things.

@rustbot modify labels: T-doc
2020-10-29 17:05:08 +01:00
bors
a53fb30e3b Auto merge of #78446 - RalfJung:box, r=Amanieu
fix Box::into_unique

https://github.com/rust-lang/rust/pull/77187/ broke Stacked Borrows pointer tagging around `Box::into_unique` (this is caused by `Box` being a special case in the type system, which box-internal code needs to account for). This PR fixes that.

r? `@Amanieu` Cc `@TimDiekmann`

Fixes https://github.com/rust-lang/rust/issues/78419.
2020-10-29 12:08:16 +00:00
Giacomo Stevanato
1f6f917f73 Added test for issue #78498 2020-10-29 12:25:02 +01:00
Giacomo Stevanato
e83666f45e Prevent String::retain from creating non-utf8 strings when abusing panic 2020-10-29 11:58:12 +01:00
Camelid
4e30e10f25 Don't say you "should" use fully qualified syntax
That recommendation was removed last year; there isn't a particular
style that is officially recommended anymore.
2020-10-28 16:49:30 -07:00
Camelid
e0eed3c558 Fix broken intra-doc link 2020-10-28 16:31:45 -07:00
Camelid
bd7cbaecd3 Explain fully qualified syntax for Rc and Arc 2020-10-28 16:31:44 -07:00
Ralf Jung
b0df3f76dc fix some incorrect aliasing in the BTree 2020-10-28 11:08:21 +01:00
Santiago Pastorino
708fc3b1a2
Add unsized_fn_params feature 2020-10-27 14:45:02 -03:00
Ralf Jung
ab374dc37c fix Box::into_unique 2020-10-27 17:02:42 +01:00
Stein Somers
e099138eb6 BTreeMap: stop mistaking node for an orderly place 2020-10-27 11:19:02 +01:00
bors
c9b606ed67 Auto merge of #78359 - ssomers:btree_cleanup_mem, r=Mark-Simulacrum
BTreeMap: move generic support functions out of navigate.rs

A preparatory step chipped off #78104, useful in general (if at all).

r? `@Mark-Simulacrum`
2020-10-27 04:01:52 +00:00
Yuki Okushi
727e93dc74
Rollup merge of #78347 - Rustin-Liu:rustin-patch-doc, r=kennytm
Add lexicographical comparison doc

close https://github.com/rust-lang/rust/issues/72255
2020-10-27 08:45:01 +09:00
bors
fd542592f0 Auto merge of #77187 - TimDiekmann:box-alloc, r=Amanieu
Support custom allocators in `Box`

r? `@Amanieu`

This pull request requires a crater run.

### Prior work:
- #71873
- #58457
- [`alloc-wg`](https://github.com/TimDiekmann/alloc-wg)-crate

Currently blocked on:
- ~#77118~
- ~https://github.com/rust-lang/chalk/issues/615 (#77515)~
2020-10-26 21:16:33 +00:00
Rustin-Liu
42844ed2cf Add lexicographical comparison doc
Add links

Fix typo

Use `sequence`

Fix typo

Fix broken link

Fix broken link

Fix broken link

Fix broken links

Fix broken links
2020-10-26 22:39:43 +08:00
Stein Somers
0da7941e1c BTreeMap: move generic functions out of navigate.rs 2020-10-26 09:31:36 +01:00
bors
b6ac411f45 Auto merge of #78015 - ssomers:btree_merge_mergers, r=Mark-Simulacrum
btree: merge the implementations of MergeIter

Also remove the gratuitous Copy bounds. Same benchmark performance.

r? `@Mark-Simulacrum`
2020-10-25 22:29:02 +00:00
Tim Diekmann
06e4497a04 Merge remote-tracking branch 'upstream/master' into box-alloc 2020-10-25 16:32:28 +01:00
Yuki Okushi
9085656512
Rollup merge of #78322 - ssomers:btree_no_min_len_at_node_level, r=Mark-Simulacrum
BTreeMap: stop mistaking node::MIN_LEN for a node level constraint

Correcting #77612 that fell into the trap of assuming that node::MIN_LEN is an imposed minimum everywhere, and trying to make it much more clear it is an offered minimum at the node level.

r? @Mark-Simulacrum
2020-10-25 18:43:47 +09:00
Yuki Okushi
72e02b015e
Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk
replace `#[allow_internal_unstable]` with `#[rustc_allow_const_fn_unstable]` for `const fn`s

`#[allow_internal_unstable]` is currently used to side-step feature gate and stability checks.
While it was originally only meant to be used only on macros, its use was expanded to `const fn`s.

This pr adds stricter checks for the usage of `#[allow_internal_unstable]` (only on macros) and introduces the `#[rustc_allow_const_fn_unstable]` attribute for usage on `const fn`s.

This pr does not change any of the functionality associated with the use of `#[allow_internal_unstable]` on macros or the usage of `#[rustc_allow_const_fn_unstable]` (instead of `#[allow_internal_unstable]`) on `const fn`s (see https://github.com/rust-lang/rust/issues/69399#issuecomment-712911540).

Note: The check for `#[rustc_allow_const_fn_unstable]` currently only validates that the attribute is used on a function, because I don't know how I would check if the function is a `const fn` at the place of the check. I therefore openend this as a 'draft pull request'.

Closes rust-lang/rust#69399

r? @oli-obk
2020-10-25 18:43:40 +09:00
Jonas Schievink
e34263d86a
Rollup merge of #77610 - hermitcore:dtors, r=m-ou-se
revise Hermit's mutex interface to support the behaviour of StaticMutex

rust-lang/rust#77147 simplifies things by splitting this Mutex type into two types matching the two use cases: StaticMutex and MovableMutex. To support the new behavior of StaticMutex, we move part of the mutex implementation into libstd.

The interface to the OS changed. Consequently, I removed a few functions, which aren't longer needed.
2020-10-24 22:39:44 +02:00
Stein Somers
3b6c4fe465 BTreeMap: stop mistaking node::MIN_LEN as a node level constraint 2020-10-24 15:24:37 +02:00
Jonas Schievink
d9acd7d148
Rollup merge of #78109 - cuviper:exhausted-rangeinc, r=dtolnay
Check for exhaustion in RangeInclusive::contains and slicing

When a range has finished iteration, `is_empty` returns true, so it
should also be the case that `contains` returns false.

Fixes #77941.
2020-10-24 14:12:01 +02:00
Tim Diekmann
693a2bf18b Rename Box::alloc to Box::alloc_ref 2020-10-23 22:45:15 +02:00
Nicolas Nattis
929f80ece9 Add a spin loop hint for Arc::downgrade 2020-10-23 16:10:56 -03:00
Yuki Okushi
dfb0d09bae
Rollup merge of #78163 - camelid:fixup-lib-docs, r=m-ou-se
Clean up lib docs

Cherry-picked out of #78094.
2020-10-23 18:26:33 +09:00