mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-28 09:02:58 +03:00
refactor: pass Span by value in set_span methods
Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
parent
f62d2d7930
commit
d98ae0a105
@ -118,39 +118,39 @@ pub enum Expression {
|
||||
}
|
||||
|
||||
impl Expression {
|
||||
pub fn set_span(&mut self, new_span: &Span) {
|
||||
pub fn set_span(&mut self, new_span: Span) {
|
||||
match self {
|
||||
Expression::Field(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Field(_, old_span) => *old_span = new_span,
|
||||
Expression::Group(value) => value.set_span(new_span),
|
||||
|
||||
Expression::Add(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Sub(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Mul(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Div(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Pow(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Add(_, old_span) => *old_span = new_span,
|
||||
Expression::Sub(_, old_span) => *old_span = new_span,
|
||||
Expression::Mul(_, old_span) => *old_span = new_span,
|
||||
Expression::Div(_, old_span) => *old_span = new_span,
|
||||
Expression::Pow(_, old_span) => *old_span = new_span,
|
||||
|
||||
Expression::Not(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Or(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::And(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Eq(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Ge(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Gt(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Le(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Lt(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Not(_, old_span) => *old_span = new_span,
|
||||
Expression::Or(_, old_span) => *old_span = new_span,
|
||||
Expression::And(_, old_span) => *old_span = new_span,
|
||||
Expression::Eq(_, old_span) => *old_span = new_span,
|
||||
Expression::Ge(_, old_span) => *old_span = new_span,
|
||||
Expression::Gt(_, old_span) => *old_span = new_span,
|
||||
Expression::Le(_, old_span) => *old_span = new_span,
|
||||
Expression::Lt(_, old_span) => *old_span = new_span,
|
||||
|
||||
Expression::IfElse(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Array(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::ArrayAccess(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::IfElse(_, old_span) => *old_span = new_span,
|
||||
Expression::Array(_, old_span) => *old_span = new_span,
|
||||
Expression::ArrayAccess(_, old_span) => *old_span = new_span,
|
||||
|
||||
Expression::Tuple(_, old_span) => *old_span = new_span.clone(),
|
||||
Expression::TupleAccess(_, _, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Tuple(_, old_span) => *old_span = new_span,
|
||||
Expression::TupleAccess(_, _, old_span) => *old_span = new_span,
|
||||
|
||||
Expression::Circuit(_, _, old_span) => *old_span = new_span.clone(),
|
||||
Expression::CircuitMemberAccess(_, _, old_span) => *old_span = new_span.clone(),
|
||||
Expression::CircuitStaticFunctionAccess(_, _, old_span) => *old_span = new_span.clone(),
|
||||
Expression::Circuit(_, _, old_span) => *old_span = new_span,
|
||||
Expression::CircuitMemberAccess(_, _, old_span) => *old_span = new_span,
|
||||
Expression::CircuitStaticFunctionAccess(_, _, old_span) => *old_span = new_span,
|
||||
|
||||
Expression::FunctionCall(_, _, old_span) => *old_span = new_span.clone(),
|
||||
Expression::CoreFunctionCall(_, _, old_span) => *old_span = new_span.clone(),
|
||||
Expression::FunctionCall(_, _, old_span) => *old_span = new_span,
|
||||
Expression::CoreFunctionCall(_, _, old_span) => *old_span = new_span,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ pub enum GroupValue {
|
||||
}
|
||||
|
||||
impl GroupValue {
|
||||
pub fn set_span(&mut self, new_span: &Span) {
|
||||
pub fn set_span(&mut self, new_span: Span) {
|
||||
match self {
|
||||
GroupValue::Single(_, old_span) => *old_span = new_span.clone(),
|
||||
GroupValue::Tuple(tuple) => tuple.span = new_span.clone(),
|
||||
GroupValue::Single(_, old_span) => *old_span = new_span,
|
||||
GroupValue::Tuple(tuple) => tuple.span = new_span,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ impl<'ast> From<DefinitionStatement<'ast>> for Statement {
|
||||
.into_iter()
|
||||
.map(|e| {
|
||||
let mut expression = Expression::from(e);
|
||||
expression.set_span(&span);
|
||||
expression.set_span(span.clone());
|
||||
|
||||
expression
|
||||
})
|
||||
@ -155,7 +155,7 @@ impl<'ast> From<ExpressionStatement<'ast>> for Statement {
|
||||
let span = Span::from(statement.span);
|
||||
let mut expression = Expression::from(statement.expression);
|
||||
|
||||
expression.set_span(&span);
|
||||
expression.set_span(span.clone());
|
||||
|
||||
Statement::Expression(expression, span)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user