From ce47b3c74f46217995192d092c4d2dd3bc954986 Mon Sep 17 00:00:00 2001 From: Brent Lewis Date: Wed, 13 Mar 2024 13:57:08 -0700 Subject: [PATCH] fiat-constify: filter out `let mut` declarations (#1057) Avoids unused variable warnings --- fiat-constify/src/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fiat-constify/src/main.rs b/fiat-constify/src/main.rs index d65fadb4..8f9c36d3 100644 --- a/fiat-constify/src/main.rs +++ b/fiat-constify/src/main.rs @@ -199,6 +199,21 @@ fn rewrite_fn_body(stmts: &[Stmt], outputs: &Outputs) -> Vec { } } else if let Stmt::Expr(Expr::Call(expr), Some(_)) = stmt { rewritten.push(Stmt::Local(rewrite_fn_call(expr.clone()))); + } else if let Stmt::Local(Local { + pat: Pat::Type(pat), + .. + }) = stmt + { + let unboxed = pat.pat.as_ref(); + if let Pat::Ident(PatIdent { + mutability: Some(_), + .. + }) = unboxed + { + // This is a mut var, in the case of fiat-crypto transformation dead code + } else { + rewritten.push(stmt.clone()); + } } else { rewritten.push(stmt.clone()); }