Skip to content

Commit 433cccc

Browse files
committed
fix(types): mark match scrutinee as moved for linear ownership
Bug 6: Expr::Match scrutinee was never marked as moved, allowing linear values used directly as match scrutinees to escape unconsumed. This broke the linear ownership invariant for match expressions. Fix: Add self.mark_expr_as_moved(env, &match_expr.expr) in the mark_expr_as_moved Match arm, so the scrutinee is consumed before arm values are processed. This is analogous to how If expressions handle their branches. Also fix: allow clippy::only_used_in_recursion on types_equal to satisfy CI clippy -D warnings. All 646 tests pass. All three acceptance gates pass.
1 parent 05f15d7 commit 433cccc

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎src/types/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,6 +4032,7 @@ impl<'a> TypeChecker<'a> {
40324032
env.merge_branch_linear_states(&then_env, false, Some(&else_env), false, if_expr.span)
40334033
}
40344034
Expr::Match(match_expr) => {
4035+
self.mark_expr_as_moved(env, &match_expr.expr)?;
40354036
let mut arm_envs = Vec::with_capacity(match_expr.arms.len());
40364037
for arm in &match_expr.arms {
40374038
let mut arm_env = env.child();
@@ -5036,6 +5037,7 @@ impl<'a> TypeChecker<'a> {
50365037
}
50375038
}
50385039

5040+
#[allow(clippy::only_used_in_recursion)]
50395041
fn types_equal(&self, a: &Type, b: &Type) -> bool {
50405042
match (a, b) {
50415043
(Type::U8, Type::U8) => true,

0 commit comments

Comments
 (0)