From e801f040c3d9a69c4dad355f4c62327ca5b8b1c0 Mon Sep 17 00:00:00 2001 From: Kelsey Merrill Date: Mon, 8 Dec 2025 20:02:32 -0500 Subject: [PATCH 1/5] make the changes suggested by the compiler to make the rust linter happy --- circ_fields/src/lib.rs | 2 +- src/front/zsharp/parser.rs | 2 +- src/ir/term/fmt.rs | 2 +- src/ir/term/text/mod.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/circ_fields/src/lib.rs b/circ_fields/src/lib.rs index cd6407a59..09f3e85d3 100644 --- a/circ_fields/src/lib.rs +++ b/circ_fields/src/lib.rs @@ -314,7 +314,7 @@ impl FieldV { let ptr: *const FullFieldV = self.0 as *const _; unsafe { &*ptr } } - fn full_cow(&self) -> std::borrow::Cow { + fn full_cow(&self) -> std::borrow::Cow<'_, FullFieldV> { if self.is_full() { std::borrow::Cow::Borrowed(self.full_ref()) } else { diff --git a/src/front/zsharp/parser.rs b/src/front/zsharp/parser.rs index 3152f1daa..dfd887b2f 100644 --- a/src/front/zsharp/parser.rs +++ b/src/front/zsharp/parser.rs @@ -106,7 +106,7 @@ impl ZLoad { /// ## Returns /// /// Returns a map from file paths to parsed files. - pub fn load>(&self, p: &P) -> HashMap { + pub fn load>(&self, p: &P) -> HashMap> { self.recursive_load(p).unwrap() } diff --git a/src/ir/term/fmt.rs b/src/ir/term/fmt.rs index 7575a37b6..da4de9c72 100644 --- a/src/ir/term/fmt.rs +++ b/src/ir/term/fmt.rs @@ -228,7 +228,7 @@ pub struct IrWrapper<'a, T> { } /// Wrap a reference for IR formatting. Uses [IrCfg::from_circ_cfg]. -pub fn wrap(t: &T) -> IrWrapper { +pub fn wrap(t: &T) -> IrWrapper<'_, T> { IrWrapper::new(t, IrCfg::from_circ_cfg()) } diff --git a/src/ir/term/text/mod.rs b/src/ir/term/text/mod.rs index 58c81030a..8446a55a7 100644 --- a/src/ir/term/text/mod.rs +++ b/src/ir/term/text/mod.rs @@ -125,7 +125,7 @@ impl Debug for TokTree<'_> { } /// Parse a token tree. -fn parse_tok_tree(bytes: &[u8]) -> TokTree { +fn parse_tok_tree(bytes: &[u8]) -> TokTree<'_> { let mut stack: Vec> = vec![vec![]]; let lex = Token::lexer(bytes).spanned(); for (t, s) in lex { From 9bda87034b6b11ea9234cc883918ca8409d12721 Mon Sep 17 00:00:00 2001 From: Kelsey Merrill Date: Tue, 9 Dec 2025 12:11:46 -0500 Subject: [PATCH 2/5] fix warnings as well as errors --- .gitignore | 1 + third_party/ZoKrates/zokrates_parser/src/lib.rs | 2 +- third_party/ZoKrates/zokrates_pest_ast/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f35286d6a..088afd558 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ scripts/aby_tests/tests /flamegraph*.svg /.ccls-cache /.vscode +CLAUDE.md diff --git a/third_party/ZoKrates/zokrates_parser/src/lib.rs b/third_party/ZoKrates/zokrates_parser/src/lib.rs index 277c611f0..be78717e3 100644 --- a/third_party/ZoKrates/zokrates_parser/src/lib.rs +++ b/third_party/ZoKrates/zokrates_parser/src/lib.rs @@ -12,7 +12,7 @@ use pest::Parser; #[grammar = "zokrates.pest"] struct ZoKratesParser; -pub fn parse(input: &str) -> Result, Error> { +pub fn parse(input: &str) -> Result, Error> { ZoKratesParser::parse(Rule::file, input) } diff --git a/third_party/ZoKrates/zokrates_pest_ast/src/lib.rs b/third_party/ZoKrates/zokrates_pest_ast/src/lib.rs index a5b49cc33..2dc7168f2 100644 --- a/third_party/ZoKrates/zokrates_pest_ast/src/lib.rs +++ b/third_party/ZoKrates/zokrates_pest_ast/src/lib.rs @@ -1124,7 +1124,7 @@ impl fmt::Display for Error { } } -pub fn generate_ast(input: &str) -> Result { +pub fn generate_ast(input: &str) -> Result, Error> { let parse_tree = parse(input).map_err(Error)?; Ok(Prog::from(parse_tree).0) } From 7bb4f907d8538231624cfbdba8b75020796ec608 Mon Sep 17 00:00:00 2001 From: Kelsey Merrill Date: Tue, 9 Dec 2025 12:19:21 -0500 Subject: [PATCH 3/5] fix more lifetime issues with all features on --- src/front/datalog/mod.rs | 4 ++-- src/front/datalog/parser.rs | 4 ++-- src/front/zsharpcurly/parser.rs | 2 +- third_party/ZoKratesCurly/zokrates_parser/src/lib.rs | 2 +- third_party/ZoKratesCurly/zokrates_pest_ast/src/lib.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/front/datalog/mod.rs b/src/front/datalog/mod.rs index 0f04def48..f67e92349 100644 --- a/src/front/datalog/mod.rs +++ b/src/front/datalog/mod.rs @@ -113,7 +113,7 @@ impl<'ast> Gen<'ast> { ) } - fn entry_rule(&mut self, name: &'ast str) -> Result<()> { + fn entry_rule(&mut self, name: &'ast str) -> Result<'_, ()> { let rule = *self .rules .get(name) @@ -291,7 +291,7 @@ impl<'ast> Gen<'ast> { } // Begin prim-rec linting - fn lint_rules(&mut self) -> Result<()> { + fn lint_rules(&mut self) -> Result<'_, ()> { let rules: Vec<&'ast ast::Rule_> = self.rules.values().cloned().collect(); let bug_if = rules.iter().try_fold(term::bool_lit(false), |x, rule| { let cond = self.lint_rule(rule)?; diff --git a/src/front/datalog/parser.rs b/src/front/datalog/parser.rs index 0e02ca6db..9924100d0 100644 --- a/src/front/datalog/parser.rs +++ b/src/front/datalog/parser.rs @@ -24,7 +24,7 @@ pub mod ast { pub use pest::Span; use pest_ast::FromPest; - fn span_into_str(span: Span) -> &str { + fn span_into_str(span: Span<'_>) -> &str { span.as_str() } @@ -534,7 +534,7 @@ pub mod ast { } #[allow(clippy::result_large_err)] -pub fn parse(file_string: &str) -> Result> { +pub fn parse(file_string: &str) -> Result, Error> { let mut pest_pairs = MyParser::parse(Rule::program, file_string)?; use from_pest::FromPest; Ok(ast::Program::from_pest(&mut pest_pairs).expect("bug in AST construction")) diff --git a/src/front/zsharpcurly/parser.rs b/src/front/zsharpcurly/parser.rs index 8265025c8..2251a0b1d 100644 --- a/src/front/zsharpcurly/parser.rs +++ b/src/front/zsharpcurly/parser.rs @@ -106,7 +106,7 @@ impl ZLoad { /// ## Returns /// /// Returns a map from file paths to parsed files. - pub fn load>(&self, p: &P) -> HashMap { + pub fn load>(&self, p: &P) -> HashMap> { self.recursive_load(p).unwrap() } diff --git a/third_party/ZoKratesCurly/zokrates_parser/src/lib.rs b/third_party/ZoKratesCurly/zokrates_parser/src/lib.rs index eb61ce2d8..8e93fb970 100644 --- a/third_party/ZoKratesCurly/zokrates_parser/src/lib.rs +++ b/third_party/ZoKratesCurly/zokrates_parser/src/lib.rs @@ -13,7 +13,7 @@ use pest::Parser; struct ZoKratesParser; #[allow(clippy::result_large_err)] -pub fn parse(input: &str) -> Result, Error> { +pub fn parse(input: &str) -> Result, Error> { ZoKratesParser::parse(Rule::file, input) } diff --git a/third_party/ZoKratesCurly/zokrates_pest_ast/src/lib.rs b/third_party/ZoKratesCurly/zokrates_pest_ast/src/lib.rs index 9f58f574a..cb21fe539 100644 --- a/third_party/ZoKratesCurly/zokrates_pest_ast/src/lib.rs +++ b/third_party/ZoKratesCurly/zokrates_pest_ast/src/lib.rs @@ -1194,7 +1194,7 @@ impl fmt::Display for Error { } #[allow(clippy::result_large_err)] -pub fn generate_ast(input: &str) -> Result { +pub fn generate_ast(input: &str) -> Result, Error> { let parse_tree = parse(input).map_err(Error)?; Ok(Prog::from(parse_tree).0) } From 1974933b095093d76388790dbd6b53fd3560631a Mon Sep 17 00:00:00 2001 From: Kelsey Merrill Date: Tue, 9 Dec 2025 12:57:27 -0500 Subject: [PATCH 4/5] linter changes for rust 1.91.0 --- src/ir/term/bv.rs | 2 +- src/ir/term/mod.rs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ir/term/bv.rs b/src/ir/term/bv.rs index 91c358038..7b68c26b0 100644 --- a/src/ir/term/bv.rs +++ b/src/ir/term/bv.rs @@ -253,7 +253,7 @@ impl BitVector { impl Display for BitVector { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - if self.width % 4 == 0 { + if self.width.is_multiple_of(4) { write!( f, "#x{:0>width$}", diff --git a/src/ir/term/mod.rs b/src/ir/term/mod.rs index 09d90dad6..48032ba3f 100644 --- a/src/ir/term/mod.rs +++ b/src/ir/term/mod.rs @@ -819,7 +819,7 @@ impl std::hash::Hash for Value { } } -#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, Default)] /// The "type" of an IR term pub enum Sort { /// bit-vectors of this width @@ -833,6 +833,7 @@ pub enum Sort { /// prime field, integers mod FieldT.modulus() Field(FieldT), /// boolean + #[default] Bool, /// Array from one sort to another, of fixed size. /// @@ -864,12 +865,6 @@ pub struct MapSort { pub val: Sort, } -impl Default for Sort { - fn default() -> Self { - Self::Bool - } -} - impl Sort { #[track_caller] /// Unwrap the bitsize of this bit-vector, panicking otherwise. From e81f8990b13d244deb7875d078c55b762803ae2b Mon Sep 17 00:00:00 2001 From: Kelsey Merrill Date: Tue, 9 Dec 2025 13:11:28 -0500 Subject: [PATCH 5/5] undo edits to .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 088afd558..f35286d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ scripts/aby_tests/tests /flamegraph*.svg /.ccls-cache /.vscode -CLAUDE.md