Skip to content

Commit

Permalink
chore: remove unused serde traits
Browse files Browse the repository at this point in the history
  • Loading branch information
zmalatrax committed Jul 4, 2024
1 parent 7c8a6b3 commit c9c219a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
3 changes: 1 addition & 2 deletions crates/cairo-lang-casm/src/ap_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions crates/cairo-lang-casm/src/cell_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]`.
Expand Down
17 changes: 8 additions & 9 deletions crates/cairo-lang-casm/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -120,7 +119,7 @@ impl Display for JumpInstruction {
}

/// Represents the InstructionBody "jmp rel <jump_offset> 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,
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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,
}
Expand Down
16 changes: 8 additions & 8 deletions crates/cairo-lang-sierra-to-casm/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Instruction>,
pub debug_info: CairoProgramDebugInfo,
Expand Down Expand Up @@ -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,
Expand All @@ -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<ReferenceValue>,
}

/// 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<BranchChanges>,
Expand All @@ -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<SierraStatementDebugInfo>,
}

/// 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<u32, ConstSegment>,
pub total_segments_size: usize,
Expand Down Expand Up @@ -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<BigInt>,
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-sierra-to-casm/src/invocations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions crates/cairo-lang-sierra-to-casm/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub type StatementRefs = OrderedHashMap<VarId, ReferenceValue>;

/// 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,
Expand Down Expand Up @@ -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,
Expand All @@ -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<CellExpression>,
}
Expand Down

0 comments on commit c9c219a

Please sign in to comment.