@@ -7,7 +7,9 @@ use std::borrow::Cow;
77use std:: cell:: Cell ;
88use std:: collections:: TryReserveErrorKind :: * ;
99use std:: fmt:: Debug ;
10+ use std:: hint;
1011use std:: iter:: InPlaceIterable ;
12+ use std:: mem;
1113use std:: mem:: { size_of, swap} ;
1214use std:: ops:: Bound :: * ;
1315use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
@@ -1107,8 +1109,31 @@ fn test_into_iter_drop_allocator() {
11071109
11081110#[ test]
11091111fn test_into_iter_zst ( ) {
1110- for _ in vec ! [ [ 0u64 ; 0 ] ] . into_iter ( ) { }
1111- for _ in vec ! [ [ 0u64 ; 0 ] ; 5 ] . into_iter ( ) . rev ( ) { }
1112+ #[ derive( Debug , Clone ) ]
1113+ struct AlignedZstWithDrop ( [ u64 ; 0 ] ) ;
1114+ impl Drop for AlignedZstWithDrop {
1115+ fn drop ( & mut self ) {
1116+ let addr = self as * mut _ as usize ;
1117+ assert ! ( hint:: black_box( addr) % mem:: align_of:: <u64 >( ) == 0 ) ;
1118+ }
1119+ }
1120+
1121+ const C : AlignedZstWithDrop = AlignedZstWithDrop ( [ 0u64 ; 0 ] ) ;
1122+
1123+ for _ in vec ! [ C ] . into_iter ( ) { }
1124+ for _ in vec ! [ C ; 5 ] . into_iter ( ) . rev ( ) { }
1125+
1126+ let mut it = vec ! [ C , C ] . into_iter ( ) ;
1127+ it. advance_by ( 1 ) . unwrap ( ) ;
1128+ drop ( it) ;
1129+
1130+ let mut it = vec ! [ C , C ] . into_iter ( ) ;
1131+ it. next_chunk :: < 1 > ( ) . unwrap ( ) ;
1132+ drop ( it) ;
1133+
1134+ let mut it = vec ! [ C , C ] . into_iter ( ) ;
1135+ it. next_chunk :: < 4 > ( ) . unwrap_err ( ) ;
1136+ drop ( it) ;
11121137}
11131138
11141139#[ test]
0 commit comments