Commit graph

488 commits

Author SHA1 Message Date
Giacomo Stevanato
387568cd56 Added SAFETY comment as request 2020-11-09 22:34:31 +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
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
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
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
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