Commit graph

540 commits

Author SHA1 Message Date
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
Yuki Okushi
39f8289e38
Rollup merge of #77969 - ryan-scott-dev:bigo-notation-consistency, r=m-ou-se
Doc formating consistency between slice sort and sort_unstable, and big O notation consistency

Updated documentation for slice sorting methods to be consistent between stable and unstable versions, which just ended up being minor formatting differences.

I also went through and updated any doc comments with big O notation to be consistent with #74010 by italicizing them rather than having them in a code block.
2020-10-23 18:26:26 +09:00
Camelid
13bc087a73 Clean up lib docs 2020-10-22 10:36:35 -07:00
Stein Somers
2c5f64f683 BTreeMap/Set: merge the implementations of MergeIter 2020-10-22 09:39:24 +02:00
Florian Warzecha
05f4a9a42a
switch allow_internal_unstable const fns to rustc_allow_const_fn_unstable 2020-10-21 20:54:20 +02:00
Yuki Okushi
f8bae8b102
Rollup merge of #78056 - ssomers:btree_chop_up_1, r=dtolnay
BTreeMap: split off most code of remove and split_off

Putting map.rs on a diet, in addition to #77851.
r? @dtolnay
2020-10-21 13:59:37 +09:00
Josh Stone
9202fbdbdb Check for exhaustion in SliceIndex for RangeInclusive 2020-10-20 17:18:08 -07:00
Stein Somers
76c466a18f BTreeMap: less sharing, more similarity between leaf and internal nodes 2020-10-20 15:13:57 +02:00
Stein Somers
7829e18899 BTreeMap: reuse BoxedNode instances directly instead of their contents 2020-10-20 13:58:11 +02:00
Yuki Okushi
c5b0a88669
Rollup merge of #77612 - ssomers:btree_cleanup_2, r=Mark-Simulacrum
BTreeMap: test invariants more thoroughly and more readably

r? @Mark-Simulacrum
2020-10-20 12:10:52 +09:00
Stein Somers
488b999fc2 BTreeMap: test invariants more thoroughly and more readably 2020-10-19 11:36:39 +02:00
bors
187b8771dc Auto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAus
Move `slice::check_range` to `RangeBounds`

Since this method doesn't take a slice anymore (#76662), it makes more sense to define it on `RangeBounds`.

Questions:
- Should the new method be `assert_len` or `assert_length`?
2020-10-18 18:50:43 +00:00
Stein Somers
003516f91a BTreeMap: split off most code of remove and split_off 2020-10-18 13:13:23 +02:00
Yuki Okushi
a0242e73bb
Rollup merge of #77851 - exrook:split-btreemap, r=dtolnay
BTreeMap: refactor Entry out of map.rs into its own file

btree/map.rs is approaching the 3000 line mark, splitting out the entry
code buys about 500 lines of headroom.

I've created this PR because the changes I've made in #77438 will push `map.rs` over the 3000 line limit and cause tidy to complain.

I picked `Entry` to factor out because it feels less tightly coupled to the rest of `BTreeMap` than the various iterator implementations.

Related: #60302
2020-10-18 04:11:07 +09:00
Alexis Bourget
1bdee96c5e Move subslice pattern tests to alloc/tests/slice.rs 2020-10-17 18:48:20 +02:00
Alexis Bourget
42271a537a Move vec swap test 2020-10-17 18:48:20 +02:00
Alexis Bourget
4fd06b9bb5 Move vec-macro-repeat test 2020-10-17 18:48:20 +02:00
Alexis Bourget
85afbd8a15 Rebase conflicts 2020-10-17 18:47:58 +02:00
Alexis Bourget
4af560ecef Move zero-sized-vec-push test 2020-10-17 18:42:14 +02:00
Dylan DPC
16b878fd0f
Rollup merge of #77932 - ssomers:btree_cleanup_gdb, r=Mark-Simulacrum
BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values

I accidentally pushed an earlier revision in #77788: it changes the index of tuples for BTreeSet from ""[{}]".format(i) to "key{}".format(i). Which doesn't seem to make the slightest difference on my linux box nor on CI. In fact, gdb doesn't make any distinction between "key{}" and "val{}" for a BTreeMap either, leading to confusing output if you test more. But easy to improve.

r? @Mark-Simulacrum
2020-10-17 03:27:18 +02:00
Dylan DPC
f40ecff964
Rollup merge of #77751 - vojtechkral:vecdeque-binary-search, r=scottmcm,dtolnay
liballoc: VecDeque: Add binary search functions

I am submitting rust-lang/rfcs#2997 as a PR as suggested by @scottmcm

I haven't yet created a tracking issue - if there's a favorable feedback I'll create one and update the issue links in the unstable attribs.
2020-10-17 03:27:15 +02:00
bors
f1b97ee7f8 Auto merge of #77997 - fusion-engineering-forks:to-string-no-shrink, r=joshtriplett
Remove shrink_to_fit from default ToString::to_string implementation.

As suggested by `@scottmcm` on Zulip. shrink_to_fit() seems like the wrong thing to do here in most use cases of to_string(). Would be intereseting to see if it makes any difference in a timer run.

r? `@joshtriplett`
2020-10-16 22:53:50 +00:00
Vojtech Kral
c7a787a327 liballoc: VecDeque: Simplify binary_search_by() 2020-10-16 20:49:19 +02:00
Vojtech Kral
e0506d1e9a liballoc: VecDeque: Add tracking issue for binary search fns 2020-10-16 18:17:55 +02:00
bors
8850893d96 Auto merge of #77850 - kornelski:resizedefault, r=dtolnay
Remove deprecated unstable Vec::resize_default

It's [been deprecated](https://github.com/rust-lang/rust/pull/57656) for 15 releases.
2020-10-16 12:11:32 +00:00
Mara Bos
0b062887db Remove shrink_to_fit from default ToString::to_string implementation.
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2020-10-16 11:15:12 +02:00
Tim Diekmann
955b37b305
Merge branch 'master' into box-alloc 2020-10-16 08:54:38 +02:00
Dylan DPC
b64b5fac40
Rollup merge of #77935 - ssomers:btree_cleanup_1, r=Mark-Simulacrum
BTreeMap: make PartialCmp/PartialEq explicit and tested

Follow-up on a topic raised in #77612

r? @Mark-Simulacrum
2020-10-16 02:10:24 +02:00
strct
8d8554d234
Fix typo in documentation 2020-10-15 16:57:19 +02:00
Ryan Scott
8446d949f1 Following #74010 by converting some newer cases of backticked O notations to be italicized 2020-10-15 23:21:26 +11:00
Ryan Scott
000ec5e2f8 Made slice sort documentation consistent between stable and unstable versions 2020-10-15 23:21:14 +11:00
Stein Somers
a22cd05965 BTreeMap: making PartialCmp/PartialEq explicit and tested 2020-10-14 14:57:24 +02:00
Stein Somers
28af355b9f BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values 2020-10-14 13:03:23 +02:00
Dylan DPC
ed34f82cbc
Rollup merge of #77870 - camelid:intra-doc-super, r=jyn514
Use intra-doc links for links to module-level docs

r? @jyn514
2020-10-14 02:30:46 +02:00
Yuki Okushi
6a596210a6
Rollup merge of #77569 - ssomers:btree_cleanup_1, r=Mark-Simulacrum
BTreeMap: type-specific variants of node_as_mut and cast_unchecked

Improves debug checking and shortens some expressions. Extracted from #77408
2020-10-14 06:02:17 +09:00
Stefan Lankes
77d98316f4
minor changes to pass the format check 2020-10-13 12:22:18 +02:00
Stefan Lankes
bc6b2ac449
move __rg_oom to the libos to avoid duplicated symbols 2020-10-13 12:06:48 +02:00
Ralf Jung
0f572a9810 explicitly talk about integer literals 2020-10-13 09:30:09 +02:00
Camelid
95221b4eb5 Use intra-doc links for links to module-level docs 2020-10-12 19:22:47 -07:00
Jacob Hughes
4b96049da2 BTreeMap: refactor Entry out of map.rs into its own file
btree/map.rs is approaching the 3000 line mark, splitting out the entry
code buys about 500 lines of headroom
2020-10-12 08:44:53 -04:00
Kornel
07637db883 Remove deprecated unstable Vec::resize_default 2020-10-12 13:36:19 +01:00
Ralf Jung
c555aabc5b clarify rules for ZST Boxes 2020-10-12 10:32:11 +02:00
Yuki Okushi
b6b6bc0a61
Rollup merge of #77738 - RalfJung:alloc-error-handler-comment, r=Amanieu
fix __rust_alloc_error_handler comment

`__rust_alloc_error_handler` was added in the same `extern` block as the allocator functions, but the comment there was not actually correct for `__rust_alloc_error_handler`. So move it down to the rest of the default allocator handling with a fixed comment. At least the comment reflects my understanding of what happens, please check carefully. :)

r? @Amanieu Cc @haraldh
2020-10-11 03:19:10 +09:00
Yuki Okushi
45e35745d3
Rollup merge of #77709 - pickfire:patch-1, r=jyn514
Link Vec leak doc to Box
2020-10-11 03:19:09 +09:00
Ivan Tham
8688fa8250
Improve vec leak wording
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-10 22:17:48 +08:00
Ivan Tham
66369a6c70
Alloc vec doc mention cannot undo leak 2020-10-10 22:12:28 +08:00
Vojtech Kral
36d9b72354 liballoc: VecDeque: Add binary search functions 2020-10-09 19:59:35 +02:00
Ralf Jung
b6bedc80c9 rename __default_lib_allocator -> __default_alloc_error_handler 2020-10-09 11:39:28 +02:00
Ralf Jung
1911d21866 also extend global allocator comment 2020-10-09 11:36:20 +02:00
Ralf Jung
6cd9b88a25 fix __rust_alloc_error_handler comment 2020-10-09 11:36:13 +02:00
Jonas Schievink
738a41b363
Rollup merge of #77449 - ssomers:btree_drain_filter_size_hint, r=Mark-Simulacrum
BTreeMap: comment why drain_filter's size_hint is somewhat pessimistic

The `size_hint` of the `DrainFilter` iterator doesn't adjust as you iterate. This hardly seems important to me, but there has been a comparable PR #64383 in the past. I guess a scenario is that you first iterate half the map manually and keep most of the key/value pairs in the map, and then tell the predicate to drain most of the key/value pairs and `.collect` the iterator over the remaining half of the map.

I am totally ambivalent whether this is better or not.

r? @Mark-Simulacrum
2020-10-08 23:23:08 +02:00
Ivan Tham
176b96516f
Link Vec leak doc to Box 2020-10-08 23:39:31 +08:00
Jacob Hughes
bf0adc3c36 Rename LayoutErr to LayoutError outside of core 2020-10-08 00:40:10 -04:00
bors
5779815f89 Auto merge of #74194 - mbrubeck:slice-eq, r=sfackler
Add PartialEq impls for Vec <-> slice

This is a follow-up to #71660 and rust-lang/rfcs#2917 to add two more missing vec/slice PartialEq impls:

```
impl<A, B> PartialEq<[B]> for Vec<A> where A: PartialEq<B> { .. }
impl<A, B> PartialEq<Vec<B>> for [A] where A: PartialEq<B> { .. }
```

Since this is insta-stable, it should go through the `@rust-lang/libs` FCP process.  Note that I used version 1.47.0 for the `stable` attribute because I assume this will not merge before the 1.46.0 branch is cut next week.
2020-10-07 01:20:11 +00:00
Tim Diekmann
f288cd2e17 Support custom allocators in Box
Remove `Box::leak_with_alloc`


Add leak-test for box with allocator


Rename `AllocErr` to `AllocError` in leak-test


Add `Box::alloc` and adjust examples to use the new API
2020-10-07 03:07:02 +02:00
Ralf Jung
fa6a4f7d37 avoid unnecessary intermediate reference and improve safety comments 2020-10-06 10:54:43 +02:00
Stein Somers
97beb074af BTreeMap: derive type-specific variants of node_as_mut and cast_unchecked 2020-10-05 13:23:38 +02:00
Ralf Jung
69669cbdb2 make IterMut Send/Sync again 2020-10-05 09:12:56 +02:00
Ralf Jung
e4c1a3867f VecDeque: avoid more aliasing issues by working with raw pointers instead of references 2020-10-05 09:12:56 +02:00
Ralf Jung
f251dc446f VecDeque: fix incorrect &mut aliasing in IterMut::next/next_back 2020-10-05 09:12:54 +02:00
Dylan DPC
9dbc9ed870
Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebank
Replace some once(x).chain(once(y)) with [x, y] IntoIter

Now that we have by-value array iterators that are [already used](25c8c53dd9/compiler/rustc_hir/src/def.rs (L305-L307))...

For example,
```diff
-        once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it)
+        IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)
```
2020-10-05 02:29:42 +02:00
Dylan DPC
23b1e3d772
Rollup merge of #77471 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
BTreeMap: refactoring around edges, missed spots

Tweaks from #77244 (and more) that are really inconsistencies in #77005.

r? @Mark-Simulacrum
2020-10-05 02:29:38 +02:00
Dylan DPC
fe087ece94
Rollup merge of #77395 - ssomers:btree_love_the_leaf_edge_comments, r=Mark-Simulacrum
BTreeMap: admit the existence of leaf edges in comments

The btree code is ambiguous about leaf edges (i.e., edges within leaf nodes). Iteration relies on them heavily, but some of the comments suggest there are no leaf edges (extracted from #77025)

r? @Mark-Simulacrum
2020-10-05 02:29:31 +02:00
Jonas Schievink
80953177ed
Rollup merge of #77445 - ssomers:btree_cleanup_7, r=Mark-Simulacrum
BTreeMap: complete the compile-time test_variance test case

Some of the items added to the new `test_sync` belonged in the old `test_variance` as well. And fixed inconsistent paths to nearby modules.
r? @Mark-Simulacrum
2020-10-04 15:45:41 +02:00
bors
0d37dca25a Auto merge of #76448 - haraldh:default_alloc_error_handler_reduced, r=Amanieu
Implement Make `handle_alloc_error` default to panic (for no_std + liballoc)

Related: https://github.com/rust-lang/rust/issues/66741

Guarded with `#![feature(default_alloc_error_handler)]` a default
`alloc_error_handler` is called, if a custom allocator is used and no
other custom `#[alloc_error_handler]` is defined.
2020-10-04 08:56:05 +00:00
Yuki Okushi
25d0650d0f
Rollup merge of #77447 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
BTreeMap: document DrainFilterInner better

r? @Mark-Simulacrum
2020-10-04 11:45:04 +09:00