From ac248beb1ad2ce575703459b698565e4843fdd24 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Thu, 27 Aug 2026 05:04:24 +0530 Subject: [PATCH 1/7] Add mutability to let statements --- crates/formality-rust/src/grammar/expr/mod.rs | 11 ++++++- crates/formality-rust/src/test.rs | 33 ++++++++++++++++++- crates/formality-rust/src/to_rust/expr.rs | 15 +++++---- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/crates/formality-rust/src/grammar/expr/mod.rs b/crates/formality-rust/src/grammar/expr/mod.rs index aee375aba..32d55dfba 100644 --- a/crates/formality-rust/src/grammar/expr/mod.rs +++ b/crates/formality-rust/src/grammar/expr/mod.rs @@ -8,6 +8,14 @@ use crate::grammar::{ mod parse_expr; +#[term] +pub enum Mutability { + #[grammar(mut)] + Mut, + #[grammar()] + Not, +} + id!(LabelId, regex = "'[a-zA-Z_][a-zA-Z0-9_]*"); #[term($id :)] @@ -73,8 +81,9 @@ pub enum Stmt { /// in the named block and dropped when that block exits. /// If no initializer is given, the variable is uninitialized /// and must be assigned before use. - #[grammar(let $?label $id : $ty $?init ;)] + #[grammar(let $mutability $?label $id : $ty $?init ;)] Let { + mutability: Mutability, label: Option