about summary refs log tree commit diff
path: root/src/liballoc/boxed.rs
diff options
context:
space:
mode:
authorTrevor Spiteri <tspiteri@ieee.org>2020-04-04 14:24:26 +0200
committerTrevor Spiteri <tspiteri@ieee.org>2020-04-04 14:30:33 +0200
commit2b718e8d9ca6efdccf4d72647cb3d3101e15b7fa (patch)
tree35051115f6fd6fb728e25c6619456a03fed85e83 /src/liballoc/boxed.rs
parent1b521f57735663de9373679cf8c6502622036bf1 (diff)
downloadrust-2b718e8d9ca6efdccf4d72647cb3d3101e15b7fa.tar.gz
rust-2b718e8d9ca6efdccf4d72647cb3d3101e15b7fa.zip
use ManuallyDrop instead of forget inside collections
This commit changes some usage of mem::forget into mem::ManuallyDrop
in some Vec, VecDeque, BTreeMap and Box methods.

Before the commit, the generated IR for some of the methods was
longer, and even after optimization, some unwinding artifacts were
still present.
Diffstat (limited to 'src/liballoc/boxed.rs')
-rw-r--r--src/liballoc/boxed.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 5406956a528..db7420954a0 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -469,8 +469,8 @@ impl<T: ?Sized> Box<T> {
     #[inline]
     #[doc(hidden)]
     pub fn into_unique(b: Box<T>) -> Unique<T> {
+        let b = mem::ManuallyDrop::new(b);
         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