@@ -8,7 +8,7 @@ use core::iter::{
88 FusedIterator , InPlaceIterable , SourceIter , TrustedLen , TrustedRandomAccessNoCoerce ,
99} ;
1010use core:: marker:: PhantomData ;
11- use core:: mem:: { self , ManuallyDrop , MaybeUninit } ;
11+ use core:: mem:: { self , ManuallyDrop , MaybeUninit , SizedTypeProperties } ;
1212#[ cfg( not( no_global_oom_handling) ) ]
1313use core:: ops:: Deref ;
1414use core:: ptr:: { self , NonNull } ;
@@ -149,7 +149,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
149149 fn next ( & mut self ) -> Option < T > {
150150 if self . ptr == self . end {
151151 None
152- } else if mem :: size_of :: < T > ( ) == 0 {
152+ } else if T :: IS_ZST {
153153 // purposefully don't use 'ptr.offset' because for
154154 // vectors with 0-size elements this would return the
155155 // same pointer.
@@ -167,7 +167,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
167167
168168 #[ inline]
169169 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
170- let exact = if mem :: size_of :: < T > ( ) == 0 {
170+ let exact = if T :: IS_ZST {
171171 self . end . addr ( ) . wrapping_sub ( self . ptr . addr ( ) )
172172 } else {
173173 unsafe { self . end . sub_ptr ( self . ptr ) }
@@ -179,7 +179,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
179179 fn advance_by ( & mut self , n : usize ) -> Result < ( ) , usize > {
180180 let step_size = self . len ( ) . min ( n) ;
181181 let to_drop = ptr:: slice_from_raw_parts_mut ( self . ptr as * mut T , step_size) ;
182- if mem :: size_of :: < T > ( ) == 0 {
182+ if T :: IS_ZST {
183183 // SAFETY: due to unchecked casts of unsigned amounts to signed offsets the wraparound
184184 // effectively results in unsigned pointers representing positions 0..usize::MAX,
185185 // which is valid for ZSTs.
@@ -209,7 +209,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
209209
210210 let len = self . len ( ) ;
211211
212- if mem :: size_of :: < T > ( ) == 0 {
212+ if T :: IS_ZST {
213213 if len < N {
214214 self . forget_remaining_elements ( ) ;
215215 // Safety: ZSTs can be conjured ex nihilo, only the amount has to be correct
@@ -253,7 +253,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
253253 // that `T: Copy` so reading elements from the buffer doesn't invalidate
254254 // them for `Drop`.
255255 unsafe {
256- if mem :: size_of :: < T > ( ) == 0 { mem:: zeroed ( ) } else { ptr:: read ( self . ptr . add ( i) ) }
256+ if T :: IS_ZST { mem:: zeroed ( ) } else { ptr:: read ( self . ptr . add ( i) ) }
257257 }
258258 }
259259}
@@ -264,7 +264,7 @@ impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A> {
264264 fn next_back ( & mut self ) -> Option < T > {
265265 if self . end == self . ptr {
266266 None
267- } else if mem :: size_of :: < T > ( ) == 0 {
267+ } else if T :: IS_ZST {
268268 // See above for why 'ptr.offset' isn't used
269269 self . end = self . end . wrapping_byte_sub ( 1 ) ;
270270
@@ -280,7 +280,7 @@ impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A> {
280280 #[ inline]
281281 fn advance_back_by ( & mut self , n : usize ) -> Result < ( ) , usize > {
282282 let step_size = self . len ( ) . min ( n) ;
283- if mem :: size_of :: < T > ( ) == 0 {
283+ if T :: IS_ZST {
284284 // SAFETY: same as for advance_by()
285285 self . end = self . end . wrapping_byte_sub ( step_size) ;
286286 } else {
0 commit comments