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
Spec: what does let _ = t do to a named t? Sema says it moves nothing, MIR moves and drops it #2074
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.
Activity
spec v7.24 (D95): let _ drops; pub const takes its value's type; ?? b…
D95 + D96: let _ drops; pub const takes its value's type; ?? below |>…