File tree 3 files changed +20
-2
lines changed 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -375,7 +375,8 @@ where
375
375
if A :: MAY_HAVE_SIDE_EFFECT && sz_a > self . len {
376
376
// FIXME(const_trait_impl): replace with `for`
377
377
let mut i = 0 ;
378
- while i < sz_a - self . len {
378
+ let upper_bound = sz_a - self . len ;
379
+ while i < upper_bound {
379
380
// since next_back() may panic we increment the counters beforehand
380
381
// to keep Zip's state in sync with the underlying iterator source
381
382
self . a_len -= 1 ;
@@ -401,7 +402,7 @@ where
401
402
if B :: MAY_HAVE_SIDE_EFFECT && sz_b > self . len {
402
403
// FIXME(const_trait_impl): replace with `for`
403
404
let mut i = 0 ;
404
- while i < sz_a - self . len {
405
+ while i < sz_b - self . len {
405
406
self . b . next_back ( ) ;
406
407
i += 1 ;
407
408
}
Original file line number Diff line number Diff line change @@ -100,3 +100,18 @@ pub fn extend_for_unit() {
100
100
}
101
101
assert_eq ! ( x, 5 ) ;
102
102
}
103
+
104
+ #[ test]
105
+ fn test_const_iter ( ) {
106
+ const X : usize = {
107
+ let mut n = 0 ;
108
+ #[ allow( for_loops_over_fallibles) ]
109
+ for a in Some ( 1 ) {
110
+ n = a;
111
+ }
112
+ n
113
+ } ;
114
+
115
+ const _: ( ) = assert ! ( X == 1 ) ;
116
+ assert_eq ! ( 1 , X ) ;
117
+ }
Original file line number Diff line number Diff line change 13
13
#![ feature( const_cell_into_inner) ]
14
14
#![ feature( const_convert) ]
15
15
#![ feature( const_hash) ]
16
+ #![ feature( const_for) ]
16
17
#![ feature( const_heap) ]
18
+ #![ feature( const_iter) ]
17
19
#![ feature( const_maybe_uninit_as_mut_ptr) ]
18
20
#![ feature( const_maybe_uninit_assume_init_read) ]
19
21
#![ feature( const_nonnull_new) ]
You can’t perform that action at this time.
0 commit comments