diff --git a/simplicity-sys/src/alloc.rs b/simplicity-sys/src/alloc.rs index 8bd9142b..b3d3fa26 100644 --- a/simplicity-sys/src/alloc.rs +++ b/simplicity-sys/src/alloc.rs @@ -7,6 +7,7 @@ use std::mem; /// [16 bytes is the greatest alignment of any architecture Rust currently supports](https://github.com/rust-lang/rust/blob/61223975d46f794466efa832bc7562b9707ecc46/library/std/src/sys/pal/common/alloc.rs). #[repr(align(16))] #[derive(Default, Copy, Clone)] +#[allow(dead_code)] pub struct AlignedType([u8; 16]); /// Minimal alignment which is valid for all C types. diff --git a/src/human_encoding/parse/ast.rs b/src/human_encoding/parse/ast.rs index c25dd95e..241b606b 100644 --- a/src/human_encoding/parse/ast.rs +++ b/src/human_encoding/parse/ast.rs @@ -3,7 +3,6 @@ //! Parsing use std::mem; -use std::str::FromStr; use std::sync::Arc; use crate::human_encoding::{Error, ErrorSet, Position, WitnessOrHole}; @@ -61,7 +60,7 @@ pub enum ExprInner { #[derive(Debug, PartialEq, Eq, Clone, Hash)] pub enum AstCmr { Expr(Arc>), - Literal(Cmr), + Literal, } /// A type, as represented in the AST @@ -395,9 +394,7 @@ impl Ast { assert_eq!(lexemes.len(), 1); assert_eq!(lexemes[0].raw.len(), 65); - Ast::Cmr(AstCmr::Literal( - Cmr::from_str(&lexemes[0].raw[1..]).unwrap(), - )) + Ast::Cmr(AstCmr::Literal) } fn expect_arrow(&mut self) -> (Option, Option) { diff --git a/src/human_encoding/parse/mod.rs b/src/human_encoding/parse/mod.rs index 4d68f46b..17a60cf4 100644 --- a/src/human_encoding/parse/mod.rs +++ b/src/human_encoding/parse/mod.rs @@ -8,7 +8,6 @@ use crate::dag::{Dag, DagLike, InternalSharing}; use crate::jet::Jet; use crate::node; use crate::types::Type; -use crate::Cmr; use std::collections::HashMap; use std::mem; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -139,7 +138,7 @@ struct ResolvedExpression { enum ResolvedCmr { Expr(Arc>), - Literal(Cmr), + Literal, } enum ResolvedInner { @@ -312,7 +311,7 @@ pub fn parse( right.in_degree.fetch_add(1, Ordering::SeqCst); ResolvedCmr::Expr(right) } - ast::AstCmr::Literal(cmr) => ResolvedCmr::Literal(*cmr), + ast::AstCmr::Literal => ResolvedCmr::Literal, }; ResolvedInner::AssertL(left, right) } @@ -323,7 +322,7 @@ pub fn parse( left.in_degree.fetch_add(1, Ordering::SeqCst); ResolvedCmr::Expr(left) } - ast::AstCmr::Literal(cmr) => ResolvedCmr::Literal(*cmr), + ast::AstCmr::Literal => ResolvedCmr::Literal, }; let right = inline_stack.pop().unwrap(); @@ -413,8 +412,8 @@ pub fn parse( | ResolvedInner::AssertR(ResolvedCmr::Expr(ref left), ref right) => { Dag::Binary(left, right) } - ResolvedInner::AssertL(ref child, ResolvedCmr::Literal(..)) - | ResolvedInner::AssertR(ResolvedCmr::Literal(..), ref child) => Dag::Unary(child), + ResolvedInner::AssertL(ref child, ResolvedCmr::Literal) + | ResolvedInner::AssertR(ResolvedCmr::Literal, ref child) => Dag::Unary(child), ResolvedInner::Inline(ref inner) => inner.as_dag().map(|node| node), } } @@ -431,10 +430,10 @@ pub fn parse( for data in expr.as_ref().post_order_iter::() { let left = data .left_index - .and_then(|idx| converted[idx].as_ref().map(Arc::clone)); + .and_then(|idx| Option::>::clone(&converted[idx])); let right = data .right_index - .and_then(|idx| converted[idx].as_ref().map(Arc::clone)); + .and_then(|idx| Option::>::clone(&converted[idx])); let maybe_inner = match data.node.inner { ResolvedInner::Missing { ref name, .. } => { @@ -482,11 +481,7 @@ pub fn parse( } }; - let name = data - .node - .name - .as_ref() - .map(Arc::clone) + let name = Option::>::clone(&data.node.name) .unwrap_or_else(|| Arc::from(namer.assign_name(inner.as_ref()).as_str())); let node = NamedConstructNode::new( diff --git a/src/lib.rs b/src/lib.rs index 7f757b0e..c4c63f0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,9 @@ // we use `bool` to represent bits and frequentely assert_eq against them clippy::bool_assert_comparison, // we use () as the environment for Core (FIXME we should probabl use a newtype) - clippy::let_unit_value + clippy::let_unit_value, + // We write map(Arc::clone) to signify that a cheap Arc is being cloned + clippy::map_clone )] #[cfg(feature = "serde")] diff --git a/src/merkle/amr.rs b/src/merkle/amr.rs index c377c852..10bb3ab2 100644 --- a/src/merkle/amr.rs +++ b/src/merkle/amr.rs @@ -65,7 +65,7 @@ impl Amr { /// Produce a CMR for a take combinator pub fn take(ty: &FinalArrow, child: Amr) -> Self { - let (a, b) = ty.source.as_sum().unwrap(); + let (a, b) = ty.source.as_product().unwrap(); let c = &ty.target; Self::TAKE_IV .update(a.tmr().into(), b.tmr().into()) diff --git a/src/node/witness.rs b/src/node/witness.rs index 3e9d5ae5..57268e41 100644 --- a/src/node/witness.rs +++ b/src/node/witness.rs @@ -59,7 +59,7 @@ impl WitnessNode { .as_ref() .map(Arc::clone) .map_disconnect(Option::>::clone) - .map_witness(|wit| wit.as_ref().map(Arc::clone)), + .map_witness(Option::>::clone), }) } @@ -83,7 +83,7 @@ impl WitnessNode { _: &PostOrderIterItem<&WitnessNode>, wit: &Option>, ) -> Result>, Self::Error> { - Ok(wit.as_ref().map(Arc::clone)) + Ok(Option::>::clone(wit)) } fn prune_case( @@ -129,7 +129,7 @@ impl WitnessNode { ) -> Result, Self::Error> { let converted_inner = inner .map(|node| node.cached_data()) - .map_witness(|wit| wit.as_ref().map(Arc::clone)); + .map_witness(Option::>::clone); // This next line does the actual retyping. let mut retyped = WitnessData::from_inner(converted_inner)?; // Sometimes we set the prune bit on nodes without setting that