Skip to content

Commit

Permalink
refactor: derive Eq trait across various structs and types + enforc…
Browse files Browse the repository at this point in the history
…e this with cargo

- Adds the `Eq` trait to derive macros a series of data structures across multiple files,
- Strictened linting rules by implementing a new clippy lint check for unpaired `PartialEq` and `Eq` derivations,
  • Loading branch information
huitseeker committed Aug 16, 2023
1 parent 4e2bb2e commit dd440f9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ xclippy = [
"-Wclippy::disallowed_methods",
"-Wclippy::match_same_arms",
"-Wclippy::cast_lossless",
"-Wclippy::derive_partial_eq_without_eq",
"-Wrust_2018_idioms",
]
10 changes: 5 additions & 5 deletions fcomm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub struct Commitment<F: LurkField> {
pub comm: F,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct OpeningRequest<F: LurkField> {
pub commitment: Commitment<F>,
pub input: Expression<F>,
Expand Down Expand Up @@ -196,7 +196,7 @@ impl<F: LurkField> FromHex for Commitment<F> {
}
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct Expression<F: LurkField> {
pub expr: LurkPtr<F>,
}
Expand Down Expand Up @@ -226,7 +226,7 @@ pub struct ZBytes {
#[cfg_attr(not(target_arch = "wasm32"), derive(Arbitrary))]
#[cfg_attr(not(target_arch = "wasm32"), proptest(no_bound))]
#[cfg_attr(not(target_arch = "wasm32"), serde_test(types(S1), zdata(true)))]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct ZStorePtr<F: LurkField> {
z_store: ZStore<F>,
z_ptr: ZExprPtr<F>,
Expand Down Expand Up @@ -261,7 +261,7 @@ impl<F: LurkField> Eq for LurkPtr<F> {}
#[cfg_attr(not(target_arch = "wasm32"), derive(Arbitrary))]
#[cfg_attr(not(target_arch = "wasm32"), proptest(no_bound))]
#[cfg_attr(not(target_arch = "wasm32"), serde_test(types(S1), zdata(true)))]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct CommittedExpression<F: LurkField + Serialize> {
pub expr: LurkPtr<F>,
#[cfg_attr(
Expand Down Expand Up @@ -336,7 +336,7 @@ impl<F: LurkField + Serialize + for<'de> Deserialize<'de>> Claim<F> {
// this. Even if not entirely realistic, something with this general *shape* is likely to play a role in a recursive
// system where the ability to aggregate proof verification more soundly is possible.
//#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Cert<F: LurkField> {
pub claim_cid: ZExprPtr<F>,
pub proof_cid: ZExprPtr<F>,
Expand Down
2 changes: 1 addition & 1 deletion src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl<'a, F: LurkField, C: Coprocessor<F>> Iterator for FrameIt<'a, Witness<F>, F
}
}

#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Witness<F: LurkField> {
pub(crate) prethunk_output_expr: Ptr<F>,
pub(crate) prethunk_output_env: Ptr<F>,
Expand Down
2 changes: 1 addition & 1 deletion src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::tag::{ContTag, ExprTag, Op1, Op2};
/// Because confusion on this point, perhaps combined with cargo-cult copying of incorrect previous usage has led to
/// inconsistencies and inaccuracies in the code base, please prefer the named Scalar forms when correspondence to a
/// named `LanguageField` is important.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(not(target_arch = "wasm32"), derive(Arbitrary))]
#[cfg_attr(not(target_arch = "wasm32"), serde_test)]
pub enum LanguageField {
Expand Down
2 changes: 1 addition & 1 deletion src/hash_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<F: LurkField> ConsStub<F> {

impl<F: LurkField> ContStub<F> {}

#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct HashWitness<Name: HashName, T, const L: usize, F: LurkField> {
pub slots: [(Name, Stub<T>); L],
_f: PhantomData<F>,
Expand Down
4 changes: 2 additions & 2 deletions src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use nom::{error::ErrorKind, AsBytes, Err, IResult, InputLength};

use crate::parser::{base, Span};

#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum ParseErrorKind<F: LurkField> {
InvalidBase16EscapeSequence(String, Option<ParseIntError>),
InvalidBaseEncoding(base::LitBase),
Expand Down Expand Up @@ -38,7 +38,7 @@ impl<F: LurkField> ParseErrorKind<F> {
}
}

#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct ParseError<I: AsBytes, F: LurkField> {
pub input: I,
pub expected: Option<&'static str>,
Expand Down
2 changes: 1 addition & 1 deletion src/z_data/z_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::z_ptr::ZPtr;

use crate::field::LurkField;

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Default)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Default)]
#[cfg_attr(not(target_arch = "wasm32"), derive(Arbitrary))]
#[cfg_attr(not(target_arch = "wasm32"), proptest(no_bound))]
#[cfg_attr(
Expand Down

0 comments on commit dd440f9

Please sign in to comment.