From f14cb96b07517b5638bf966e6f6e30b946552912 Mon Sep 17 00:00:00 2001 From: Dan Schatzberg Date: Thu, 4 Sep 2014 17:59:28 -0400 Subject: [PATCH] Use RawPtr::offset when size_of::() > 0 --- src/libcollections/vec.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 6fdf2fce0a2..b3a3609bdce 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -848,7 +848,11 @@ impl Vec { let ptr = self.ptr; let cap = self.cap; let begin = self.ptr as *const T; - let end = (self.ptr as uint + self.len()) as *const T; + let end = if mem::size_of::() == 0 { + (ptr as uint + self.len()) as *const T; + } else { + ptr.offset(self.len() as int) + }; mem::forget(self); MoveItems { allocation: ptr, cap: cap, ptr: begin, end: end } }