about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/lib.rs2
-rw-r--r--src/liballoc/vec.rs7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 69fc007ab7c..5ca39442342 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -99,11 +99,11 @@
 #![feature(lang_items)]
 #![feature(needs_allocator)]
 #![feature(nonzero)]
-#![feature(offset_to)]
 #![feature(optin_builtin_traits)]
 #![feature(pattern)]
 #![feature(pin)]
 #![feature(ptr_internals)]
+#![feature(ptr_offset_from)]
 #![feature(rustc_attrs)]
 #![feature(slice_get_slice)]
 #![feature(slice_rsplit)]
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index 4b883b5bce7..0f74743ca49 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -2394,9 +2394,10 @@ impl<T> Iterator for IntoIter<T> {
 
     #[inline]
     fn size_hint(&self) -> (usize, Option<usize>) {
-        let exact = match self.ptr.offset_to(self.end) {
-            Some(x) => x as usize,
-            None => (self.end as usize).wrapping_sub(self.ptr as usize),
+        let exact = if mem::size_of::<T>() == 0 {
+            (self.end as usize).wrapping_sub(self.ptr as usize)
+        } else {
+            unsafe { self.end.offset_from(self.ptr) as usize }
         };
         (exact, Some(exact))
     }