rust/src/liballoc
bors 9fe5cb5342 Auto merge of #56161 - RalfJung:vecdeque-stacked-borrows, r=SimonSapin
VecDeque: fix for stacked borrows

`VecDeque` violates a version of stacked borrows where creating a shared reference is not enough to make a location *mutably accessible* from raw pointers (and I think that is the version we want).  There are two problems:

* Creating a `NonNull<T>` from `&mut T` goes through `&T` (inferred for a `_`), then `*const T`, then `NonNull<T>`. That means in this stricter version of Stacked Borrows, we cannot actually write to such a `NonNull` because it was created from a shared reference! This PR fixes that by going from `&mut T` to `*mut T` to `*const T`.
* `VecDeque::drain` creates the `Drain` struct by *first* creating a `NonNull` from `self` (which is an `&mut VecDeque`), and *then* calling `self.buffer_as_mut_slice()`. The latter reborrows `self`, asserting that `self` is currently the unique pointer to access this `VecDeque`, and hence invalidating the `NonNull` that was created earlier. This PR fixes that by instead using `self.buffer_as_slice()`, which only performs read accesses and creates only shared references, meaning the raw pointer (`NonNull`) remains valid.

It is possible that other methods on `VecDeque` do something similar, miri's test coverage of `VecDeque` is sparse to say the least.

Cc @nikomatsakis @Gankro
2018-12-13 07:12:19 +00:00
..
benches Fix slice's benchmarks 2018-10-10 22:55:12 -07:00
collections Auto merge of #56161 - RalfJung:vecdeque-stacked-borrows, r=SimonSapin 2018-12-13 07:12:19 +00:00
tests std: Depend directly on crates.io crates 2018-12-11 21:08:22 -08:00
alloc.rs global allocators: add a few comments 2018-11-12 09:01:57 +01:00
borrow.rs Review fix 2018-08-15 22:06:35 +03:00
boxed.rs Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
boxed_test.rs add FromIterator<A> to Box<[A]> 2018-11-10 11:43:39 +01:00
Cargo.toml std: Depend directly on crates.io crates 2018-12-11 21:08:22 -08:00
fmt.rs Rollup merge of #55050 - tshepang:repetition, r=steveklabnik 2018-10-18 12:54:54 +08:00
lib.rs Auto merge of #55366 - Amanieu:stable_layout, r=Amanieu 2018-11-08 06:52:27 +00:00
macros.rs fix some typos 2017-11-21 15:33:45 +01:00
prelude.rs Add the alloc::prelude module 2018-07-07 23:08:43 +02:00
raw_vec.rs Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
rc.rs Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
slice.rs Auto merge of #56463 - ljedrz:slice_concat_join, r=nikic 2018-12-09 22:39:44 +00:00
str.rs liballoc: mark str.to_owned() and String::from(&str) as #[inline]. 2018-09-27 12:08:03 +02:00
string.rs Fix typo 2018-12-09 14:10:20 -07:00
sync.rs Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
task.rs Switch to bootstrapping from 1.29 beta 2018-08-01 11:59:08 -06:00
vec.rs Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00