diff options
| author | bors <bors@rust-lang.org> | 2019-05-24 00:21:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-05-24 00:21:00 +0000 |
| commit | fd8e23c6b2902299cb76e89d868fbb84f48035ab (patch) | |
| tree | 923ca6815de27674d8c5767f691c072eb369c74b /src/liballoc | |
| parent | 8869ee03d7f258e1b76a11c6fbb01b5708a9f504 (diff) | |
| parent | 92fda925e3c945dccb1e5b6c3f662bfd9aadedc3 (diff) | |
| download | rust-fd8e23c6b2902299cb76e89d868fbb84f48035ab.tar.gz rust-fd8e23c6b2902299cb76e89d868fbb84f48035ab.zip | |
Auto merge of #61105 - Centril:rollup-t9lemjf, r=Centril
Rollup of 6 pull requests Successful merges: - #59545 (Use arenas to avoid Lrc in queries #2) - #61054 (Suggest dereferencing on assignment to mutable borrow) - #61056 (tweak discriminant on non-nullary enum diagnostic) - #61082 (fix dangling reference in Vec::append) - #61086 (Box::into_unique: do the reborrow-to-raw *after* destroying the Box) - #61098 (Fix overflowing literal lint in loops) Failed merges: r? @ghost
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 11 | ||||
| -rw-r--r-- | src/liballoc/tests/vec.rs | 5 | ||||
| -rw-r--r-- | src/liballoc/vec.rs | 2 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 024594517d9..97c2d8e7a8e 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -253,15 +253,16 @@ impl<T: ?Sized> Box<T> { #[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")] #[inline] #[doc(hidden)] - pub fn into_unique(mut b: Box<T>) -> Unique<T> { + pub fn into_unique(b: Box<T>) -> Unique<T> { + let mut unique = b.0; + mem::forget(b); // Box is kind-of a library type, but recognized as a "unique pointer" by // Stacked Borrows. This function here corresponds to "reborrowing to // a raw pointer", but there is no actual reborrow here -- so // without some care, the pointer we are returning here still carries - // the `Uniq` tag. We round-trip through a mutable reference to avoid that. - let unique = unsafe { b.0.as_mut() as *mut T }; - mem::forget(b); - unsafe { Unique::new_unchecked(unique) } + // the tag of `b`, with `Unique` permission. + // We round-trip through a mutable reference to avoid that. + unsafe { Unique::new_unchecked(unique.as_mut() as *mut T) } } /// Consumes and leaks the `Box`, returning a mutable reference, diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 545332bcd6a..3307bdf94f9 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::borrow::Cow; use std::mem::size_of; use std::{usize, isize}; @@ -763,6 +761,7 @@ fn from_into_inner() { it.next().unwrap(); let vec = it.collect::<Vec<_>>(); assert_eq!(vec, [2, 3]); + #[cfg(not(miri))] // Miri does not support comparing dangling pointers assert!(ptr != vec.as_ptr()); } @@ -971,6 +970,7 @@ fn test_reserve_exact() { } #[test] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve() { // These are the interesting cases: @@ -1073,6 +1073,7 @@ fn test_try_reserve() { } #[test] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve_exact() { // This is exactly the same as test_try_reserve with the method changed. diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 073d3ab5937..dc661a267e2 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1094,7 +1094,7 @@ impl<T> Vec<T> { let count = (*other).len(); self.reserve(count); let len = self.len(); - ptr::copy_nonoverlapping(other as *const T, self.get_unchecked_mut(len), count); + ptr::copy_nonoverlapping(other as *const T, self.as_mut_ptr().add(len), count); self.len += count; } |
