about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2014-11-12 23:34:32 +0100
committerTobias Bucher <tobiasbucher5991@gmail.com>2014-11-12 23:34:32 +0100
commit59b3c83a819567a1ca8b7c8535dad5bf73c855b1 (patch)
tree2b2d9986342d94d0657b80b1c9a28e6cf45758c6
parente1149f0223e28b320a3f4d66981ce09607fb6535 (diff)
downloadrust-59b3c83a819567a1ca8b7c8535dad5bf73c855b1.tar.gz
rust-59b3c83a819567a1ca8b7c8535dad5bf73c855b1.zip
Fix `Vec::map_in_place` not doing what is written in the comment
-rw-r--r--src/libcollections/vec.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 0e3799ed9ac..4a341898606 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1661,7 +1661,10 @@ impl<T> Vec<T> {
             // Create a `Vec` from our `PartialVecZeroSized` and make sure the
             // destructor of the latter will not run. None of this can panic.
             let mut result = Vec::new();
-            unsafe { result.set_len(pv.num_u); }
+            unsafe {
+                result.set_len(pv.num_u);
+                mem::forget(pv);
+            }
             result
         }
     }