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
§21.1 rule 1 not enforced for a plain &local binding: mutate the place, then use the reference — no diagnostic #1249
Spec §21.1 rule 1: active shared borrows of a place are invalidated when the place is mutated (assignment, a mut self call, IndexPlace writes) and a later use of the borrow is rejected. The checker enforces this for map views (Option[&V] from get, "cannot mutate self while x is a live view into it") and element views (#887), but not for a plain reference binding of a local:
fn main:
var v: Vec[str] = Vec.new()
v.push("a".clone())
let s = &v
v.push("b".clone()) // also: v.clear(), v.pop(), v[0] = ..., v = Vec.new()
print(f"{s.len()}") // accepted; reads through an invalidated view
Matrix (installed compiler, main e16c6db): v.push, v.clear(), v.pop(), v[0] = x, v = Vec.new() — all accepted, both for let s = &v and for the auto-referenced let s: &Vec[str] = v (#1244, same borrow). consume(move v) then use is rejected (rule 2/3 fire; rule 1 does not). Same with str: let s = &x; x = "cd"; s.len().
record_view_binding_from_expr sets the deps and register_view_binding_borrows creates the SHARED borrow, so the borrow exists; the mutation paths (check_mutation_against_views, assignment, mut self dispatch) do not consult it for this binding shape. Own ownership batch.
Mechanism (lldb on the release binary, breakpoint set -r register_view_binding_borrows): the borrow is only ever attached from check_let_binding → record_view_binding_from_expr → register_view_binding_borrows, and it attaches per dep. For let s = &v over an owned v, collect_expr_view_deps yields nothing ("only carries ref-typed origins") and the bare-place fallback in record_view_binding_from_expr adds the root only for an NK_INDEX initializer (#887) — and, since #1250, for an auto-referenced typed let. So s has no dep, the SHARED borrow created at &v keeps borrow_refs[i] == 0, and check_mutation_against_views skips it (if ref_sym == 0: continue, SemaCheck.w ~22481).
Fix shape: the bare-place fallback should cover every place initializer that is a borrow of an owned root — &place, &v[i], &s.field, the auto-ref — so §21.1 rule 1 has a ref symbol to report. Own ownership batch with the drop/move audits.
Activity
`let s: &T = place` borrows the place instead of moving it (#1244, §3…
ehartford commentedon Sep 21, 2026
Mechanism (lldb on the release binary,
breakpoint set -r register_view_binding_borrows): the borrow is only ever attached fromcheck_let_binding → record_view_binding_from_expr → register_view_binding_borrows, and it attaches per dep. Forlet s = &vover an ownedv,collect_expr_view_depsyields nothing ("only carries ref-typed origins") and the bare-place fallback inrecord_view_binding_from_expradds the root only for anNK_INDEXinitializer (#887) — and, since #1250, for an auto-referenced typed let. Soshas no dep, the SHARED borrow created at&vkeepsborrow_refs[i] == 0, andcheck_mutation_against_viewsskips it (if ref_sym == 0: continue, SemaCheck.w ~22481).Fix shape: the bare-place fallback should cover every place initializer that is a borrow of an owned root —
&place,&v[i],&s.field, the auto-ref — so §21.1 rule 1 has a ref symbol to report. Own ownership batch with the drop/move audits.A use inside an f-string keeps a view alive: expr_uses_symbol walks i…