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
D115: a match guard after an owned-Vec slice pattern that removes elements is refused #2289
Spec §9.7 (D115): [first, ..rest] over an owned Vec takes it apart by value in its own buffer: the tail elements come off the end, the head off the front (each by remove), and the remainder is the Vec itself.
A match arm runs its guard after its bindings, and a failed guard puts each moved binding back into the subject (restore_pattern_moves, which writes the value back to the place it came from). An element removed from a Vec came from no place: putting a tail element back is a push, a head element needs an insert at the front, and Vec has no insert (the stdlib's containers come from migrated corpora: STC, Phase 3). [..rest] alone removes nothing and is restored.
Until then Sema refuses the combination with an error naming this issue:
match make():
[first, ..rest] if first.ok => ...
Expected: compiles; a failed guard leaves the subject whole for the next arm.
Fix: put removed elements back (push for the tail, a front insert for the head), or bind by view during the guard and move after it passes, as Rust does.
changed the title [-]D115: a match guard after an owned-Vec slice pattern with head bindings is refused[/-][+]D115: a match guard after an owned-Vec slice pattern that removes elements is refused[/+]on Oct 9, 2026
D115 Amendment 1 (#2292) gives an owned Vec remainder a start offset in the header; a failed guard then puts head elements back by moving the offset back and tail elements back into the capacity they left. This issue closes with that implementation.
Merged to main in c97a008 (#2352): a failed guard puts a head back through the prefix its O(1) take left (with_vec_restore_front_es) and a tail back by push, after the remainder is back in the subject; fixture behav_2289_guard_after_owned_list_take.w.
Activity
[-]D115: a match guard after an owned-Vec slice pattern with head bindings is refused[/-][+]D115: a match guard after an owned-Vec slice pattern that removes elements is refused[/+]ehartford commentedon Oct 9, 2026
D115 Amendment 1 (#2292) gives an owned Vec remainder a start offset in the header; a failed guard then puts head elements back by moving the offset back and tail elements back into the capacity they left. This issue closes with that implementation.
D115: a slice pattern's rest names the remaining elements; subject ow…
#2289: the compile-error fixture that pinned the guard refusal is ret…
D115 Amendment 1 step 2: the List header's word 3 is `start`, an owne…
ehartford commentedon Oct 12, 2026
Merged to main in c97a008 (#2352): a failed guard puts a head back through the prefix its O(1) take left (with_vec_restore_front_es) and a tail back by push, after the remainder is back in the subject; fixture behav_2289_guard_after_owned_list_take.w.