rust/library/alloc/src
bors 335ffbfa54 Auto merge of #94472 - JmPotato:use_maybeuninit_for_vecdeque, r=m-ou-se
Use MaybeUninit in VecDeque to remove the undefined behavior of slice

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Ref https://github.com/rust-lang/rust/issues/74189. Adjust the code to follow the [doc.rust-lang.org/reference/behavior-considered-undefined.html](https://doc.rust-lang.org/reference/behavior-considered-undefined.html).

* Change the return type of `buffer_as_slice` from `&[T]` to `&[MaybeUninit<T>]`.
* Add some corresponding safety comments.

Benchmark results:

master 8d6f527530

```rust
test collections::vec_deque::tests::bench_pop_back_100       ... bench:          47 ns/iter (+/- 1)
test collections::vec_deque::tests::bench_pop_front_100      ... bench:          50 ns/iter (+/- 4)
test collections::vec_deque::tests::bench_push_back_100      ... bench:          69 ns/iter (+/- 10)
test collections::vec_deque::tests::bench_push_front_100     ... bench:          72 ns/iter (+/- 6)
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     145,891 ns/iter (+/- 7,975)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     141,647 ns/iter (+/- 3,711)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     120,132 ns/iter (+/- 4,078)
```

This PR

```rust
test collections::vec_deque::tests::bench_pop_back_100       ... bench:          48 ns/iter (+/- 2)
test collections::vec_deque::tests::bench_pop_front_100      ... bench:          51 ns/iter (+/- 3)
test collections::vec_deque::tests::bench_push_back_100      ... bench:          73 ns/iter (+/- 2)
test collections::vec_deque::tests::bench_push_front_100     ... bench:          73 ns/iter (+/- 2)
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     131,796 ns/iter (+/- 5,440)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     137,563 ns/iter (+/- 3,349)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     128,815 ns/iter (+/- 3,289)
```
2022-03-11 19:23:55 +00:00
..
alloc Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
collections Auto merge of #94472 - JmPotato:use_maybeuninit_for_vecdeque, r=m-ou-se 2022-03-11 19:23:55 +00:00
raw_vec Add a unit test for zero-sized types in RawVec. 2021-11-26 19:30:45 +11:00
rc Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
sync Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
vec Rollup merge of #94826 - allgoewer:fix-retain-documentation, r=yaahc 2022-03-11 03:32:06 +01:00
alloc.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
borrow.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
boxed.rs Rollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, r=Mark-Simulacrum 2022-03-10 23:12:57 +01:00
fmt.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
lib.rs Stabilize const_fn_fn_ptr_basics and const_fn_trait_bound 2022-03-07 08:47:15 -08:00
macros.rs Add diagnostic items for macros 2022-01-06 14:59:33 +00:00
raw_vec.rs Fix typo 2022-02-12 12:31:33 +01:00
rc.rs Add tracking issue and impl for Rc. 2022-02-03 10:40:31 +00:00
slice.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
str.rs Use spare_capacity_mut instead of invalid unchecked indexing 2021-12-08 17:58:57 -05:00
string.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
sync.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
task.rs Document From implementations for Waker and RawWaker 2021-04-22 14:16:33 -07:00
tests.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00