Issue #2934: with on a binding taken from a tuple of views is not refused (NK1343 from rustc instead of NK1173)

Open and answer this issue on GitHub.

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

Probe

struct P { x: i64, y: bool }
enum E { A(P), B }
fn g(e: ref E, d: ref E) -> P? {
    return match (e, d) { (E::A(p), E::B) => p with { x: 2 }, else => null }
}
fn main() throws {
    let p = P { x: 0, y: true }
    let r = g(E::A(p), E::B) ?? p
    println(f"{r.x} {r.y}")
}

On c2554dfb this gives NK1343.

Expected

NK1173 (“with needs the value itself, but this is only a view of a P”), as the same with gives on match e { E::A(p) => p with { x: 2 }, ... }.

Suspected cause

Not traced. Possibly the checker’s NK1173 check does not see the view through a pattern on a tuple subject.

To build

  1. A binding taken from a tuple of views is a view for the NK1173 check.
  2. The probe becomes a test with its .stderr.

Done when

The probe gives NK1173.

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