Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fd8e23c

Browse files
committedMay 24, 2019
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
2 parents 8869ee0 + 92fda92 commit fd8e23c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+555
-408
lines changed
 

‎Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,7 @@ dependencies = [
28772877
"rustc_errors 0.0.0",
28782878
"rustc_target 0.0.0",
28792879
"serialize 0.0.0",
2880+
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
28802881
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
28812882
"syntax 0.0.0",
28822883
"syntax_ext 0.0.0",

‎src/liballoc/boxed.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,16 @@ impl<T: ?Sized> Box<T> {
253253
#[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")]
254254
#[inline]
255255
#[doc(hidden)]
256-
pub fn into_unique(mut b: Box<T>) -> Unique<T> {
256+
pub fn into_unique(b: Box<T>) -> Unique<T> {
257+
let mut unique = b.0;
258+
mem::forget(b);
257259
// Box is kind-of a library type, but recognized as a "unique pointer" by
258260
// Stacked Borrows. This function here corresponds to "reborrowing to
259261
// a raw pointer", but there is no actual reborrow here -- so
260262
// without some care, the pointer we are returning here still carries
261-
// the `Uniq` tag. We round-trip through a mutable reference to avoid that.
262-
let unique = unsafe { b.0.as_mut() as *mut T };
263-
mem::forget(b);
264-
unsafe { Unique::new_unchecked(unique) }
263+
// the tag of `b`, with `Unique` permission.
264+
// We round-trip through a mutable reference to avoid that.
265+
unsafe { Unique::new_unchecked(unique.as_mut() as *mut T) }
265266
}
266267

267268
/// Consumes and leaks the `Box`, returning a mutable reference,

0 commit comments

Comments
 (0)
Please sign in to comment.