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
An explicit move of a field while a view of it is live is accepted; the view reads the blank #1530
Spec: §2.2 (D32) — "An explicit move place.field … a vacate is a write"; §21.1 / §3.8 — a view's origin may not be written while the view is live; §3.8 "A binding names what's there … an unannotated let binds the view unchanged … uniform across field projections and collection element access."
type S { s: str, n: i32 }
fn main:
var x = S { s: "x" ++ "y", n: 1 }
let p = x.s
let q = move x.s
print(p)
print(q)
Actual (stage1 of origin/main ba2d5d1): compiles; prints an empty line, then xy. p is a view of x.s (MIR binds it as an alias place), the explicit vacate blanks x.s (reset-on-move) while p is still used, and p reads the blank. Memory-safe by the blank, wrong by the spec.
The same vacate under an element view is rejected (let e = v[0] then v.remove(0) while e is live), and an assignment x.s = "z".clone() under the same field view is rejected ("cannot mutate x while p is a live view into it").
Expected: move x.s while a view of x.s (or of x) is live is the same view-invalidation error as the assignment.
Found while building the #1408 field-join matrix (the view join inherits the hole: let p = if c: x.s else: y.s; let q = move x.s; print(p)).
Activity
Sema/MIR: a join whose arms are all non-Copy field places is a view o…
Sema/MIR: a join whose arms are all non-Copy field places is a view o…
Sema: a field view borrows its field's path, not its whole root (#1530 …
Spell the transfers the field-view borrow and the method-path move ch…
Sema: a field view borrows its root, and an explicit move is a write …
Sema: a field view borrows its field's path, not its whole root (#1530 …
Spell the transfers the field-view borrow and the method-path move ch…
D69: a generator's views are live for the whole loop over it — the bo…
D69: a generator's views are live for the whole loop over it — the bo…
D69: a generator's views are live for the whole loop over it — the bo…
D69: a generator's views are live for the whole loop over it — the bo…
D69: a generator's views are live for the whole loop over it — the bo…
D69 follow-ups: generic and method gen fn, comprehensions and goto ov…
Sema: an unannotated `let` of a Copy field binds a view, as a Copy el…
Type checker: D74 entry sources and chain moves, field-view bindings (#…