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
A view returned through a match or let-else pattern binding loses its origin: use-after-free accepted #2187
Spec §21.1 rule 6; D22 (patterns are transparent to view origins).
type Thing { name: str }
enum Src ephemeral:
One(&Thing)
Two(&Thing)
fn at_match(s: &Src) -> &str:
match s:
.One(v) => &v.name
.Two(v) => &v.name
fn outer() -> &str:
let t = Thing { name: "alpha".to_owned() }
let s: Src = .One(&t)
at_match(&s)
print(outer())
Expected: returned view may outlive its origin at at_match(&s).
Actual: it compiles and prints freed data. explain:effect:at_match:s shows eff=[read]: no escape_view.
Two causes:
A body whose tail is a view publishes its parameter escape effects only at body level, after the scope teardown, when a pattern binding origins are gone. This affects let-else too.
The view-origin walkers (compute_expr_view_origin_mask, the storage mask, collect_expr_view_deps) do not walk match arms, so the facts frozen on each arm are never read.
Activity
D44: map traversal observes: keys(), values() and iter() are view ite…
D44: map traversal observes; keys/values/iter are view iterators; Has…
ehartford commentedon Oct 5, 2026
Fixed on main by stack #2196 (merged as efb765c), battery green on a21e326; the regression test for it landed with the fix.
D44 map transfers, D97 TotalF64, deep-debugging tools, and the fixes …