Skip to content

Spec: what does let _ = t do to a named t? Sema says it moves nothing, MIR moves and drops it #2074

Closed

Description

@ehartford

Needs Eric's ruling (brief given 2026-10-03).

On main, Sema's move check treats a wildcard let _ = x as moving nothing (SemaCheck.w, "#D5/P1"), while MirLower moves x into the discard and drops it there. So this is accepted and reads a moved value:

fn f(h: str) -> i64:
    let _ = h
    h.len()      // returns 0

The spec only says _ is "an explicit discard binding" (lexical-and-binding-rules.md). test/spec/spec_ss02_4_expression_temporaries.w pins that let _ = t drops t at that line.

  • A: discard consumes — t is dropped at the let _; a later use is "use of moved value". Matches the spec test.
  • B: wildcard observes — t is untouched and drops at scope end; the spec test changes.

A phase 5 commit (#2043) had implemented B in MIR; it was withdrawn from stack #2072 because it changed drop timing without a ruling and turned the spec test red. Whichever is ruled, Sema and MIR must agree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions