From c9c219a7ec6b3b92d337928d3b0b00e8a6545bf8 Mon Sep 17 00:00:00 2001 From: malatrax Date: Thu, 4 Jul 2024 15:31:57 +0200 Subject: [PATCH] chore: remove unused serde traits --- crates/cairo-lang-casm/src/ap_change.rs | 3 +-- crates/cairo-lang-casm/src/cell_expression.rs | 2 -- crates/cairo-lang-casm/src/instructions.rs | 17 ++++++++--------- .../cairo-lang-sierra-to-casm/src/compiler.rs | 16 ++++++++-------- .../src/invocations/mod.rs | 2 +- .../cairo-lang-sierra-to-casm/src/references.rs | 6 +++--- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/crates/cairo-lang-casm/src/ap_change.rs b/crates/cairo-lang-casm/src/ap_change.rs index 5571300470e..e934866225d 100644 --- a/crates/cairo-lang-casm/src/ap_change.rs +++ b/crates/cairo-lang-casm/src/ap_change.rs @@ -3,13 +3,12 @@ use core::fmt::Display; use cairo_lang_utils::casts::IntoOrPanic; use crate::operand::{BinOpOperand, CellRef, DerefOrImmediate, Register, ResOperand}; -use serde::{Deserialize, Serialize}; #[cfg(test)] #[path = "ap_change_test.rs"] mod test; -#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] pub enum ApChange { Known(usize), Unknown, diff --git a/crates/cairo-lang-casm/src/cell_expression.rs b/crates/cairo-lang-casm/src/cell_expression.rs index c9ff061f8e5..ccecc9ed83c 100644 --- a/crates/cairo-lang-casm/src/cell_expression.rs +++ b/crates/cairo-lang-casm/src/cell_expression.rs @@ -5,7 +5,6 @@ use num_bigint::BigInt; use num_traits::cast::ToPrimitive; #[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum CellOperator { Add, Sub, @@ -26,7 +25,6 @@ impl core::fmt::Display for CellOperator { /// The expression representing a cell in the casm memory. #[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CellExpression { Deref(CellRef), /// Represents an expression of the form `[[cell_ref] + offset]`. diff --git a/crates/cairo-lang-casm/src/instructions.rs b/crates/cairo-lang-casm/src/instructions.rs index 0fa86b42366..db44116d2a1 100644 --- a/crates/cairo-lang-casm/src/instructions.rs +++ b/crates/cairo-lang-casm/src/instructions.rs @@ -4,14 +4,13 @@ use core::fmt::Display; use crate::hints::{Hint, PythonicHint}; use crate::operand::{CellRef, DerefOrImmediate, ResOperand}; -use serde::{Deserialize, Serialize}; #[cfg(test)] #[path = "instructions_test.rs"] mod test; // An enum of Cairo instructions. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub enum InstructionBody { AddAp(AddApInstruction), AssertEq(AssertEqInstruction), @@ -47,7 +46,7 @@ impl Display for InstructionBody { } /// Represents an instruction, including the ap++ flag (inc_ap). -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct Instruction { pub body: InstructionBody, pub inc_ap: bool, @@ -80,7 +79,7 @@ impl Display for Instruction { } /// Represents a call instruction "call rel/abs target". -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct CallInstruction { pub target: DerefOrImmediate, pub relative: bool, @@ -100,7 +99,7 @@ impl CallInstruction { } /// Represents the InstructionBody "jmp rel/abs target". -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct JumpInstruction { pub target: DerefOrImmediate, pub relative: bool, @@ -120,7 +119,7 @@ impl Display for JumpInstruction { } /// Represents the InstructionBody "jmp rel if condition != 0". -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct JnzInstruction { pub jump_offset: DerefOrImmediate, pub condition: CellRef, @@ -153,7 +152,7 @@ pub fn op_size_based_on_res_operands(operand: &ResOperand) -> usize { } /// Represents the InstructionBody "a = b" for two operands a, b. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct AssertEqInstruction { pub a: CellRef, pub b: ResOperand, @@ -170,7 +169,7 @@ impl Display for AssertEqInstruction { } /// Represents a return instruction, "ret". -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct RetInstruction {} impl Display for RetInstruction { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { @@ -185,7 +184,7 @@ impl RetInstruction { } /// Represents the InstructionBody "ap += op" for a given operand op. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct AddApInstruction { pub operand: ResOperand, } diff --git a/crates/cairo-lang-sierra-to-casm/src/compiler.rs b/crates/cairo-lang-sierra-to-casm/src/compiler.rs index e27a61526bf..1d2c486e3ca 100644 --- a/crates/cairo-lang-sierra-to-casm/src/compiler.rs +++ b/crates/cairo-lang-sierra-to-casm/src/compiler.rs @@ -189,7 +189,7 @@ impl CasmCairoProgram { } /// The casm program representation. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct CairoProgram { pub instructions: Vec, pub debug_info: CairoProgramDebugInfo, @@ -270,7 +270,7 @@ impl CairoProgram { } /// The debug information of a compilation from Sierra to casm. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct SierraStatementDebugInfo { /// The start offset of the sierra statement within the bytecode. pub start_offset: usize, @@ -284,21 +284,21 @@ pub struct SierraStatementDebugInfo { /// Additional debug information for a Sierra statement, depending on its kind /// (invoke/return/dummy). -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub enum StatementKindDebugInfo { Return(ReturnStatementDebugInfo), Invoke(InvokeStatementDebugInfo), } /// Additional debug information for a return Sierra statement. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct ReturnStatementDebugInfo { /// The references of a Sierra return statement. pub ref_values: Vec, } /// Additional debug information for an invoke Sierra statement. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct InvokeStatementDebugInfo { /// The result branch changes of a Sierra invoke statement. pub result_branch_changes: Vec, @@ -307,14 +307,14 @@ pub struct InvokeStatementDebugInfo { } /// The debug information of a compilation from Sierra to casm. -#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct CairoProgramDebugInfo { /// The debug information per Sierra statement. pub sierra_statement_info: Vec, } /// The information about the constants used in the program. -#[derive(Debug, Eq, PartialEq, Default, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Default, Clone)] pub struct ConstsInfo { pub segments: OrderedHashMap, pub total_segments_size: usize, @@ -409,7 +409,7 @@ impl ConstsInfo { } /// The data for a single segment. -#[derive(Debug, Eq, PartialEq, Default, Clone, Serialize, Deserialize)] +#[derive(Debug, Eq, PartialEq, Default, Clone)] pub struct ConstSegment { /// The values in the segment. pub values: Vec, diff --git a/crates/cairo-lang-sierra-to-casm/src/invocations/mod.rs b/crates/cairo-lang-sierra-to-casm/src/invocations/mod.rs index 3b89705ff7b..72787cecf3e 100644 --- a/crates/cairo-lang-sierra-to-casm/src/invocations/mod.rs +++ b/crates/cairo-lang-sierra-to-casm/src/invocations/mod.rs @@ -105,7 +105,7 @@ pub enum ApTrackingChange { /// Describes the changes to the set of references at a single branch target, as well as changes to /// the environment. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct BranchChanges { /// New references defined at a given branch. /// should correspond to BranchInfo.results. diff --git a/crates/cairo-lang-sierra-to-casm/src/references.rs b/crates/cairo-lang-sierra-to-casm/src/references.rs index 1a1e53d0794..8df75304529 100644 --- a/crates/cairo-lang-sierra-to-casm/src/references.rs +++ b/crates/cairo-lang-sierra-to-casm/src/references.rs @@ -28,7 +28,7 @@ pub type StatementRefs = OrderedHashMap; /// A Sierra reference to a value. /// Corresponds to an argument or return value of a Sierra statement. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct ReferenceValue { pub expression: ReferenceExpression, pub ty: ConcreteTypeId, @@ -75,7 +75,7 @@ impl core::fmt::Display for IntroductionPoint { /// A Sierra reference to a value. /// Returned from a libfunc. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct OutputReferenceValue { pub expression: ReferenceExpression, pub ty: ConcreteTypeId, @@ -96,7 +96,7 @@ pub enum OutputReferenceValueIntroductionPoint { } /// A collection of Cell Expression which represents one logical object. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct ReferenceExpression { pub cells: Vec, }