Skip to content

Commit

Permalink
use mem::zeroed to make up ZST values
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 16, 2018
1 parent 61f0a2b commit 357c5da
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2410,8 +2410,8 @@ impl<T> Iterator for IntoIter<T> {
// 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);
Expand Down Expand Up @@ -2450,8 +2450,8 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
// 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);

Expand Down

0 comments on commit 357c5da

Please sign in to comment.