File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -608,7 +608,8 @@ where
608608 if A :: MAY_HAVE_SIDE_EFFECT && sz_a > self . len {
609609 // FIXME(const_trait_impl): replace with `for`
610610 let mut i = 0 ;
611- while i < sz_a - self . len {
611+ let upper_bound = sz_a - self . len ;
612+ while i < upper_bound {
612613 // since next_back() may panic we increment the counters beforehand
613614 // to keep Zip's state in sync with the underlying iterator source
614615 self . a_len -= 1 ;
@@ -634,7 +635,7 @@ where
634635 if B :: MAY_HAVE_SIDE_EFFECT && sz_b > self . len {
635636 // FIXME(const_trait_impl): replace with `for`
636637 let mut i = 0 ;
637- while i < sz_a - self . len {
638+ while i < sz_b - self . len {
638639 self . b . next_back ( ) ;
639640 i += 1 ;
640641 }
Original file line number Diff line number Diff line change @@ -100,3 +100,17 @@ pub fn extend_for_unit() {
100100 }
101101 assert_eq ! ( x, 5 ) ;
102102}
103+
104+ #[ test]
105+ fn test_const_iter ( ) {
106+ const X : usize = {
107+ let mut n = 0 ;
108+ for a in Some ( 1 ) {
109+ n = a;
110+ }
111+ n
112+ } ;
113+
114+ const _: ( ) = assert ! ( X == 1 ) ;
115+ assert_eq ! ( 1 , X ) ;
116+ }
Original file line number Diff line number Diff line change 1212#![ feature( const_cell_into_inner) ]
1313#![ feature( const_convert) ]
1414#![ feature( const_hash) ]
15+ #![ feature( const_for) ]
1516#![ feature( const_heap) ]
17+ #![ feature( const_iter) ]
1618#![ feature( const_maybe_uninit_as_mut_ptr) ]
1719#![ feature( const_maybe_uninit_assume_init_read) ]
1820#![ feature( const_nonnull_new) ]
You can’t perform that action at this time.
0 commit comments