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 pattern binding's view ends at its last use, as a let view's does: whole @ .Click(tag, n) => use(tag) + take(whole) is refused #3548
type Tag { name: str }
enum Ev:
Click(tag: Tag, n: i32)
fn handle(e: Ev) -> i32:
match move e:
whole @ .Click(tag, n) => tag.name.len() as i32 + take(whole)
error: 'whole' is moved while 'tag' still views it
tag views whole and is last read before take(whole). A let k = tag.name.len() before the move does not help: the binding counts as viewing until the arm ends.
A view bound with let is already judged by its last use. This compiles and runs:
let v: List[Tok] = [Tok { id: 1 }, Tok { id: 2 }]
let x = v[0] // a view of v
print(x.id)
let w = v // accepted: x is not read again
So the gap is the pattern binding, not views in general: a name bound from a place by a pattern is held to its scope where a let view is held to its last use.
Expected. The two agree: a pattern binding that is not read after the move does not refuse it.
Workaround. Read what is needed in a match on a borrow of the value that ends before the move.
changed the title [-]A view ends at its last use: `whole @ .Click(tag, n) => use(tag) + take(whole)` is refused though `tag` is never read after the move[/-][+]A pattern binding's view ends at its last use, as a let view's does: `whole @ .Click(tag, n) => use(tag) + take(whole)` is refused[/+]on Nov 23, 2026
Activity
[-]A view ends at its last use: `whole @ .Click(tag, n) => use(tag) + take(whole)` is refused though `tag` is never read after the move[/-][+]A pattern binding's view ends at its last use, as a let view's does: `whole @ .Click(tag, n) => use(tag) + take(whole)` is refused[/+]A pattern binding's view ends at its last use, as a let view's does (#…