File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,7 @@ where
200200 } else if A :: MAY_HAVE_SIDE_EFFECT && self . index < self . a . size ( ) {
201201 let i = self . index ;
202202 self . index += 1 ;
203+ self . len += 1 ;
203204 // match the base implementation's potential side effects
204205 // SAFETY: we just checked that `i` < `self.a.len()`
205206 unsafe {
@@ -258,7 +259,7 @@ where
258259 if sz_a != sz_b {
259260 let sz_a = self . a . size ( ) ;
260261 if A :: MAY_HAVE_SIDE_EFFECT && sz_a > self . len {
261- for _ in 0 ..sz_a - cmp :: max ( self . len , self . index ) {
262+ for _ in 0 ..sz_a - self . len {
262263 self . a . next_back ( ) ;
263264 }
264265 }
Original file line number Diff line number Diff line change @@ -245,3 +245,23 @@ fn test_double_ended_zip() {
245245 assert_eq ! ( it. next_back( ) , Some ( ( 3 , 3 ) ) ) ;
246246 assert_eq ! ( it. next( ) , None ) ;
247247}
248+
249+ #[ test]
250+ fn test_issue_82282 ( ) {
251+ fn overflowed_zip ( arr : & [ i32 ] ) -> impl Iterator < Item = ( i32 , & ( ) ) > {
252+ static UNIT_EMPTY_ARR : [ ( ) ; 0 ] = [ ] ;
253+
254+ let mapped = arr. into_iter ( ) . map ( |i| * i) ;
255+ let mut zipped = mapped. zip ( UNIT_EMPTY_ARR . iter ( ) ) ;
256+ zipped. next ( ) ;
257+ zipped
258+ }
259+
260+ let arr = [ 1 , 2 , 3 ] ;
261+ let zip = overflowed_zip ( & arr) . zip ( overflowed_zip ( & arr) ) ;
262+
263+ assert_eq ! ( zip. size_hint( ) , ( 0 , Some ( 0 ) ) ) ;
264+ for _ in zip {
265+ panic ! ( ) ;
266+ }
267+ }
You can’t perform that action at this time.
0 commit comments