Skip to content

Commit 357c5da

Browse files
committed
use mem::zeroed to make up ZST values
1 parent 61f0a2b commit 357c5da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/liballoc/vec.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2410,8 +2410,8 @@ impl<T> Iterator for IntoIter<T> {
24102410
// same pointer.
24112411
self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T;
24122412

2413-
// Read from a properly aligned pointer to make up a value of this ZST.
2414-
Some(ptr::read(NonNull::dangling().as_ptr()))
2413+
// Make up a value of this ZST.
2414+
Some(mem::zeroed())
24152415
} else {
24162416
let old = self.ptr;
24172417
self.ptr = self.ptr.offset(1);
@@ -2450,8 +2450,8 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
24502450
// See above for why 'ptr.offset' isn't used
24512451
self.end = arith_offset(self.end as *const i8, -1) as *mut T;
24522452

2453-
// Read from a properly aligned pointer to make up a value of this ZST.
2454-
Some(ptr::read(NonNull::dangling().as_ptr()))
2453+
// Make up a value of this ZST.
2454+
Some(mem::zeroed())
24552455
} else {
24562456
self.end = self.end.offset(-1);
24572457

0 commit comments

Comments
 (0)