diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 02393a185b1d..7fc4453fec5b 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2410,8 +2410,8 @@ impl Iterator for IntoIter { // same pointer. self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T; - // Read from a properly aligned pointer to make up a value of this ZST. - Some(ptr::read(NonNull::dangling().as_ptr())) + // Make up a value of this ZST. + Some(mem::zeroed()) } else { let old = self.ptr; self.ptr = self.ptr.offset(1); @@ -2450,8 +2450,8 @@ impl DoubleEndedIterator for IntoIter { // See above for why 'ptr.offset' isn't used self.end = arith_offset(self.end as *const i8, -1) as *mut T; - // Read from a properly aligned pointer to make up a value of this ZST. - Some(ptr::read(NonNull::dangling().as_ptr())) + // Make up a value of this ZST. + Some(mem::zeroed()) } else { self.end = self.end.offset(-1);