diff --git a/src/front/c/ast_utils.rs b/src/front/c/ast_utils.rs index c9840a9a..56dc3ba6 100644 --- a/src/front/c/ast_utils.rs +++ b/src/front/c/ast_utils.rs @@ -61,7 +61,7 @@ pub fn name_from_decl(decl: &Declarator) -> String { pub fn compress_type(ts: Vec>) -> Option { if ts.len() == 1 { - return ts.first().unwrap().clone(); + ts.first().unwrap().clone() } else { let mut signed: bool = true; let mut _void: bool = false; diff --git a/src/front/c/mod.rs b/src/front/c/mod.rs index 8f4bb485..ed777890 100644 --- a/src/front/c/mod.rs +++ b/src/front/c/mod.rs @@ -183,7 +183,7 @@ impl CGen { /// TODO: Refactor with s_type_ / d_type_ fn type_(&mut self, t: &TypeSpecifier) -> Option { - return match t { + match t { TypeSpecifier::Void => None, TypeSpecifier::Int => Some(Ty::Int(true, 32)), TypeSpecifier::Unsigned => Some(Ty::Int(false, 32)), @@ -244,7 +244,7 @@ impl CGen { } } _ => unimplemented!("Type {:#?} not implemented yet.", t), - }; + } } fn get_inner_derived_type(&mut self, base_ty: &Ty, d: &DerivedDeclarator) -> Ty { @@ -1134,12 +1134,11 @@ impl CGen { } }; } - Statement::Expression(expr) => match expr { - Some(e) => { + Statement::Expression(expr) => { + if let Some(e) = expr { self.gen_expr(&e.node); } - None => {} - }, + } Statement::For(for_stmt) => { // TODO: Add enter_breakable self.circ_enter_scope(); diff --git a/src/front/datalog/error.rs b/src/front/datalog/error.rs index a9b423a1..3e8023fc 100644 --- a/src/front/datalog/error.rs +++ b/src/front/datalog/error.rs @@ -34,7 +34,7 @@ pub struct Error<'ast> { pub span: Option>, } -impl<'ast> Display for Error<'ast> { +impl Display for Error<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { writeln!(f, "Error: {}", self.kind)?; if let Some(s) = &self.span { @@ -47,7 +47,7 @@ impl<'ast> Display for Error<'ast> { } } -impl<'ast> From for Error<'ast> { +impl From for Error<'_> { fn from(error_kind: ErrorKind) -> Self { Error { kind: error_kind, @@ -56,7 +56,7 @@ impl<'ast> From for Error<'ast> { } } -impl<'ast> From for Error<'ast> { +impl From for Error<'_> { fn from(circ: crate::circify::CircError) -> Self { Error { kind: ErrorKind::Circify(circ), diff --git a/src/front/zsharp/mod.rs b/src/front/zsharp/mod.rs index 124039d6..516e4c75 100644 --- a/src/front/zsharp/mod.rs +++ b/src/front/zsharp/mod.rs @@ -133,7 +133,7 @@ struct ZGen<'ast> { #[derive(Debug, Clone, PartialEq, Hash, Eq)] struct FnCallImplInput(bool, Vec, Vec<(String, T)>, PathBuf, String); -impl<'ast> Drop for ZGen<'ast> { +impl Drop for ZGen<'_> { fn drop(&mut self) { use std::mem::take; diff --git a/src/front/zsharp/zvisit/zstmtwalker/mod.rs b/src/front/zsharp/zvisit/zstmtwalker/mod.rs index 3b33a49b..9e6dc89a 100644 --- a/src/front/zsharp/zvisit/zstmtwalker/mod.rs +++ b/src/front/zsharp/zvisit/zstmtwalker/mod.rs @@ -729,7 +729,7 @@ impl<'ast, 'ret> ZStatementWalker<'ast, 'ret> { } } -impl<'ast, 'ret> ZVisitorMut<'ast> for ZStatementWalker<'ast, 'ret> { +impl<'ast> ZVisitorMut<'ast> for ZStatementWalker<'ast, '_> { fn visit_return_statement(&mut self, ret: &mut ast::ReturnStatement<'ast>) -> ZVisitorResult { if self.rets.len() != ret.expressions.len() { return Err(ZVisitorError( diff --git a/src/front/zsharp/zvisit/zstmtwalker/zexprtyper.rs b/src/front/zsharp/zvisit/zstmtwalker/zexprtyper.rs index fef808b8..202dca99 100644 --- a/src/front/zsharp/zvisit/zstmtwalker/zexprtyper.rs +++ b/src/front/zsharp/zvisit/zstmtwalker/zexprtyper.rs @@ -59,7 +59,7 @@ impl<'ast, 'ret, 'wlk> ZExpressionTyper<'ast, 'ret, 'wlk> { } } -impl<'ast, 'ret, 'wlk> ZVisitorMut<'ast> for ZExpressionTyper<'ast, 'ret, 'wlk> { +impl<'ast> ZVisitorMut<'ast> for ZExpressionTyper<'ast, '_, '_> { fn visit_expression(&mut self, expr: &mut ast::Expression<'ast>) -> ZVisitorResult { use ast::Expression::*; if self.ty.is_some() { diff --git a/src/ir/opt/link.rs b/src/ir/opt/link.rs index 96feccbe..e368e557 100644 --- a/src/ir/opt/link.rs +++ b/src/ir/opt/link.rs @@ -45,7 +45,7 @@ pub fn link_one(callee: &Computation, values: Vec) -> Term { ) } -impl<'f> Linker<'f> { +impl Linker<'_> { /// Ensure that a totally linked version of `name` is in the cache. fn link_all(&mut self, name: &str) { if !self.cache.contains_key(name) { @@ -66,7 +66,7 @@ impl<'f> Linker<'f> { /// Rewrites a term, inlining function calls along the way. /// /// Assumes that the callees are already inlined. Panics otherwise. -impl<'f> RewritePass for Linker<'f> { +impl RewritePass for Linker<'_> { fn visit Vec>( &mut self, _computation: &mut Computation, diff --git a/src/ir/term/dist.rs b/src/ir/term/dist.rs index 002d53da..88f68ec5 100644 --- a/src/ir/term/dist.rs +++ b/src/ir/term/dist.rs @@ -267,7 +267,7 @@ impl rand::distributions::Distribution for UniformBitVector { pub(crate) struct UniformFieldV<'a>(&'a FieldT); -impl<'a> rand::distributions::Distribution for UniformFieldV<'a> { +impl rand::distributions::Distribution for UniformFieldV<'_> { fn sample(&self, rng: &mut R) -> FieldV { self.0.random_v(rng) } @@ -275,7 +275,7 @@ impl<'a> rand::distributions::Distribution for UniformFieldV<'a> { pub(crate) struct UniformValue<'a>(pub &'a Sort); -impl<'a> rand::distributions::Distribution for UniformValue<'a> { +impl rand::distributions::Distribution for UniformValue<'_> { fn sample(&self, rng: &mut R) -> Value { match self.0 { Sort::Bool => Value::Bool(rng.gen()), @@ -314,6 +314,7 @@ impl rand::distributions::Distribution for FixedSizeDist { } #[cfg(test)] +/// Utilities for random testing. pub mod test { use super::*; @@ -323,6 +324,7 @@ pub mod test { use rand::SeedableRng; #[derive(Clone, Debug)] + /// A random term with only Boolean descendents and values for its variables. pub struct PureBool(pub Term, pub FxHashMap); impl Arbitrary for PureBool { @@ -353,6 +355,7 @@ pub mod test { } #[derive(Clone)] + /// A random term and values for its variables. pub struct ArbitraryTerm(pub Term); impl std::fmt::Debug for ArbitraryTerm { diff --git a/src/ir/term/fmt.rs b/src/ir/term/fmt.rs index 4df16d97..aaee2d88 100644 --- a/src/ir/term/fmt.rs +++ b/src/ir/term/fmt.rs @@ -281,7 +281,7 @@ impl<'a, 'b> IrFormatter<'a, 'b> { } } -impl<'a, 'b> Write for IrFormatter<'a, 'b> { +impl Write for IrFormatter<'_, '_> { fn write_str(&mut self, s: &str) -> FmtResult { self.writer.write_str(s) } @@ -666,13 +666,13 @@ fn fmt_term_with_bindings(t: &Term, f: &mut IrFormatter) -> FmtResult { Ok(()) } -impl<'a> Display for IrWrapper<'a, Term> { +impl Display for IrWrapper<'_, Term> { fn fmt(&self, f: &mut Formatter) -> FmtResult { write!(f, "{self:?}") } } -impl<'a> Debug for IrWrapper<'a, Term> { +impl Debug for IrWrapper<'_, Term> { fn fmt(&self, f: &mut Formatter) -> FmtResult { let cfg = IrCfg::from_circ_cfg(); let f = &mut IrFormatter::new(f, &cfg); diff --git a/src/ir/term/text/mod.rs b/src/ir/term/text/mod.rs index cbd47096..58c81030 100644 --- a/src/ir/term/text/mod.rs +++ b/src/ir/term/text/mod.rs @@ -94,7 +94,7 @@ enum TokTree<'src> { use TokTree::*; -impl<'src> Display for TokTree<'src> { +impl Display for TokTree<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Leaf(_, l) => write!(f, "{}", from_utf8(l).unwrap()), @@ -115,7 +115,7 @@ impl<'src> Display for TokTree<'src> { } } -impl<'src> Debug for TokTree<'src> { +impl Debug for TokTree<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Leaf(_, l) => write!(f, "{}", from_utf8(l).unwrap()), diff --git a/src/target/r1cs/bellman.rs b/src/target/r1cs/bellman.rs index 4a7429d0..f7e8ae52 100644 --- a/src/target/r1cs/bellman.rs +++ b/src/target/r1cs/bellman.rs @@ -72,7 +72,7 @@ pub(super) fn get_modulus() -> Integer { /// bellman prover. pub struct SynthInput<'a>(&'a ProverData, Option<&'a FxHashMap>); -impl<'a, F: PrimeField> Circuit for SynthInput<'a> { +impl Circuit for SynthInput<'_> { #[track_caller] fn synthesize(self, cs: &mut CS) -> std::result::Result<(), SynthesisError> where diff --git a/src/target/r1cs/trans.rs b/src/target/r1cs/trans.rs index 43aec59d..e98c4e52 100644 --- a/src/target/r1cs/trans.rs +++ b/src/target/r1cs/trans.rs @@ -1167,6 +1167,7 @@ pub fn to_r1cs(cs: &Computation, cfg: &CircCfg) -> R1cs { } #[cfg(test)] +/// Tests for this module. pub mod test { use super::*;