You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
for cannot iterate an iterator adapter: §13.5's for (i, item) in collection.enumerate() does not compile #2152
Spec: §13.5 shows for (i, item) in collection.enumerate():; §13.1: "for loops, .zip(), .peekable(), .windows() — all work as you'd expect"; §13.6 uses [w.clone(): i for (i, w) in vocab.enumerate()].
Today (v0.15.3.0, main 3f1aa3d), with let xs: Vec[i32] = [1, 2, 3]:
Loop
Result
for (i, x) in xs.enumerate(): …
unknown method 'enumerate' for type 'Vec[i32]'
for (i, x) in xs.iter().enumerate(): …
cannot iterate over `EnumerateIter[VecIter[i32], i32]`: a `for` iterable implements `Iter[T]` …
for x in xs.iter() |> filter(it > 1): …
same refusal, FilterIter[VecIter[i32], i32]
for x in xs.iter() |> map(it * 2): …
same, MapIter[…]
for (a, b) in xs.iter() |> zip(xs.iter()): …
same, ZipIter[…]
[(i, w.len()) for (i, w) in names.enumerate()]
refused at names.enumerate()
The adapters work as pipeline stages feeding count/sum/collect, but none is a for iterable, and enumerate is not a method of a collection.
Also: for i, x in xs: print(x) (two names, no parentheses) parses, binds something as an index, and then fails in MIR lowering ([mir-var-miss] sym=x), an internal error for a spelling the spec does not have; it should be a parse error or the indexed loop.
Expected: every adapter is a for iterable (it has a next()), collection.enumerate() exists, and the comprehension form follows.
Activity
v.iter() over elements that own something yields views; every iterato…
v.iter() over elements that own something yields views; every iterato…
ehartford commentedon Oct 5, 2026
Fixed on main baa84b2 (#2150); battery green on the stack.