Issue #2930: zip over io::lines() is refused with NK2701 (its item is typed (String, ?))

Open and answer this issue on GitHub.

bug, ready · opened 2026-11-29 · updated 2026-11-29 · 0 comments

Probe

use std::io
fn main() throws {
    let xs = [1, 2, 3]
    for (l, x) in io::lines().zip(xs.iter()) { println(f"{l} {x}") }
}

On 9f01bae8 this gives NK2701: “A for over a sequence of (String, ?) gives one value at a time, but you’re binding 2”.

Expected

It prints each input line next to 1, 2 and 3 (Seq::zip, Part II).

Suspected cause

The item’s second type is ?. The likely place is the checker’s typing of zip when the receiver is a stream.

To build

  1. zip on a stream receiver types its item as (String, T), with T taken from the argument’s item type.
  2. The for over it is one loop (ADR-chain-loop-v1 D6).
  3. The probe becomes a test in tests/compiler/tests/ with its .stdin and .stdout.

Done when

The probe prints its three pairs.

Found during “A chain over io::lines() is one loop the compiler writes, a kept chain a state it writes, and the view steps leave Rust (ADR-chain-loop-v1 D6, D7)” (#2899).

Back to Open Issues