From 8d915339a0841435bb02df159c336ad1efa3ea2f Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 12 May 2022 16:24:17 +0200 Subject: [PATCH] span refactor: fix build + simplify &span --- compiler/ast/src/input/input_value.rs | 8 ++--- compiler/ast/src/input/program_input.rs | 2 +- compiler/ast/src/input/program_state.rs | 2 +- .../ast/src/passes/reconstructing_director.rs | 2 +- compiler/parser/src/parser/context.rs | 4 +-- compiler/parser/src/parser/expression.rs | 8 ++--- compiler/parser/src/parser/file.rs | 12 +++---- compiler/parser/src/parser/input.rs | 2 +- compiler/parser/src/parser/mod.rs | 2 +- compiler/parser/src/parser/statement.rs | 18 +++++----- compiler/parser/src/tokenizer/mod.rs | 2 +- compiler/passes/src/symbol_table/table.rs | 2 +- .../passes/src/symbol_table/variable_scope.rs | 2 +- .../src/type_checker/check_expressions.rs | 34 +++++++++---------- .../src/type_checker/check_statements.rs | 6 ++-- compiler/passes/src/type_checker/checker.rs | 4 +-- leo/errors/src/common/macros.rs | 4 +-- leo/errors/src/emitter/mod.rs | 10 +++--- 18 files changed, 62 insertions(+), 62 deletions(-) diff --git a/compiler/ast/src/input/input_value.rs b/compiler/ast/src/input/input_value.rs index 6eca1e38dd..8a2687b592 100644 --- a/compiler/ast/src/input/input_value.rs +++ b/compiler/ast/src/input/input_value.rs @@ -38,7 +38,7 @@ impl TryFrom<(Type, Expression)> for InputValue { match (type_, value) { (Type::Address, ValueExpression::Address(value, _)) => Self::Address(value), (Type::Boolean, ValueExpression::Boolean(value, span)) => { - let bool_value = value.parse::().map_err(|_| ParserError::unexpected_eof(&span))?; // TODO: change error + let bool_value = value.parse::().map_err(|_| ParserError::unexpected_eof(span))?; // TODO: change error Self::Boolean(bool_value) } (Type::Char, ValueExpression::Char(value)) => Self::Char(value), @@ -48,18 +48,18 @@ impl TryFrom<(Type, Expression)> for InputValue { if expected == actual { Self::Integer(expected, value) } else { - return Err(InputError::unexpected_type(expected.to_string(), actual, &span).into()); + return Err(InputError::unexpected_type(expected.to_string(), actual, span).into()); } } (x, y) => { - return Err(InputError::unexpected_type(x, &y, &y.span()).into()); + return Err(InputError::unexpected_type(x, &y, y.span()).into()); } } } (type_, Expression::Unary(unary)) if unary.op == UnaryOperation::Negate => { InputValue::try_from((type_, *unary.inner))? } - (_type_, expr) => return Err(InputError::illegal_expression(&expr, &expr.span()).into()), + (_type_, expr) => return Err(InputError::illegal_expression(&expr, expr.span()).into()), }) } } diff --git a/compiler/ast/src/input/program_input.rs b/compiler/ast/src/input/program_input.rs index 858bdb2a03..55ab527c98 100644 --- a/compiler/ast/src/input/program_input.rs +++ b/compiler/ast/src/input/program_input.rs @@ -35,7 +35,7 @@ impl TryFrom for ProgramInput { sym::registers => &mut registers, _ => { return Err( - InputError::unexpected_section(&["main", "registers"], section.name, §ion.span).into(), + InputError::unexpected_section(&["main", "registers"], section.name, section.span).into(), ) } }; diff --git a/compiler/ast/src/input/program_state.rs b/compiler/ast/src/input/program_state.rs index 6d12aa2bae..b3ecc3a644 100644 --- a/compiler/ast/src/input/program_state.rs +++ b/compiler/ast/src/input/program_state.rs @@ -39,7 +39,7 @@ impl TryFrom for ProgramState { return Err(InputError::unexpected_section( &["state", "record", "state_leaf"], section.name, - §ion.span, + section.span, ) .into()); } diff --git a/compiler/ast/src/passes/reconstructing_director.rs b/compiler/ast/src/passes/reconstructing_director.rs index 0139b089c8..5cd29a1510 100644 --- a/compiler/ast/src/passes/reconstructing_director.rs +++ b/compiler/ast/src/passes/reconstructing_director.rs @@ -233,7 +233,7 @@ impl ReconstructingDirector { match &console_function_call.function { ConsoleFunction::Error(_) => ConsoleFunction::Error(formatted), ConsoleFunction::Log(_) => ConsoleFunction::Log(formatted), - _ => return Err(AstError::impossible_console_assert_call(&args.span).into()), + _ => return Err(AstError::impossible_console_assert_call(args.span).into()), } } }; diff --git a/compiler/parser/src/parser/context.rs b/compiler/parser/src/parser/context.rs index f9515630b8..fe7d7fff41 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -159,7 +159,7 @@ impl<'a> ParserContext<'a> { /// Expects an [`Identifier`], or errors. pub fn expect_ident(&mut self) -> Result { self.eat_identifier() - .ok_or_else(|| ParserError::unexpected_str(&self.token.token, "ident", &self.token.span).into()) + .ok_or_else(|| ParserError::unexpected_str(&self.token.token, "ident", self.token.span).into()) } /// Returns a reference to the next token if it is a [`GroupCoordinate`], or [None] if @@ -250,7 +250,7 @@ impl<'a> ParserContext<'a> { /// Returns an unexpected error at the current token. fn unexpected(&self, expected: impl Display) -> Result { - Err(ParserError::unexpected(&self.token.token, expected, &self.token.span).into()) + Err(ParserError::unexpected(&self.token.token, expected, self.token.span).into()) } /// Eats the expected `token`, or errors. diff --git a/compiler/parser/src/parser/expression.rs b/compiler/parser/src/parser/expression.rs index b1a4771032..fce644b3bb 100644 --- a/compiler/parser/src/parser/expression.rs +++ b/compiler/parser/src/parser/expression.rs @@ -230,7 +230,7 @@ impl ParserContext<'_> { loop { if self.eat(&Token::Dot) { let curr = &self.token; - return Err(ParserError::unexpected_str(&curr.token, "int or ident", &curr.span).into()); + return Err(ParserError::unexpected_str(&curr.token, "int or ident", curr.span).into()); } if !self.check(&Token::LeftParen) { @@ -261,7 +261,7 @@ impl ParserContext<'_> { if !trailing && tuple.len() == 1 { Ok(tuple.remove(0)) } else { - Err(ParserError::unexpected("A tuple expression.", "A valid expression.", &span).into()) + Err(ParserError::unexpected("A tuple expression.", "A valid expression.", span).into()) } } @@ -302,7 +302,7 @@ impl ParserContext<'_> { let int_ty = Self::token_to_int_type(suffix).expect("unknown int type token"); Expression::Value(ValueExpression::Integer(int_ty, value, full_span)) } - None => return Err(ParserError::implicit_values_not_allowed(value, &span).into()), + None => return Err(ParserError::implicit_values_not_allowed(value, span).into()), } } Token::True => Expression::Value(ValueExpression::Boolean("true".into(), span)), @@ -323,7 +323,7 @@ impl ParserContext<'_> { span, }), token => { - return Err(ParserError::unexpected_str(token, "expression", &span).into()); + return Err(ParserError::unexpected_str(token, "expression", span).into()); } }) } diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index 23d994c3da..a64e526b5e 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -26,7 +26,7 @@ impl ParserContext<'_> { while self.has_next() { match &self.token.token { - Token::Ident(sym::test) => return Err(ParserError::test_function(&self.token.span).into()), + Token::Ident(sym::test) => return Err(ParserError::test_function(self.token.span).into()), // Const functions share the first token with the global Const. Token::Const if self.peek_is_function() => { let (id, function) = self.parse_function_declaration()?; @@ -54,7 +54,7 @@ impl ParserContext<'_> { .map(|x| format!("'{}'", x)) .collect::>() .join(", "), - &token.span, + token.span, ) } @@ -64,7 +64,7 @@ impl ParserContext<'_> { let constant = self.eat(&Token::Constant).then(|| self.prev_token.span); let const_ = self.eat(&Token::Const).then(|| self.prev_token.span); - if let Some(span) = &const_ { + if let Some(span) = const_ { self.emit_warning(ParserWarning::const_parameter_or_input(span)); } @@ -74,10 +74,10 @@ impl ParserContext<'_> { (None, None, None) => Ok(ParamMode::Private), (Some(_), None, None) => Ok(ParamMode::Public), (Some(m1), Some(m2), None) | (Some(m1), None, Some(m2)) | (None, Some(m1), Some(m2)) => { - Err(ParserError::inputs_multiple_variable_types_specified(&(m1 + m2)).into()) + Err(ParserError::inputs_multiple_variable_types_specified(m1 + m2).into()) } (Some(m1), Some(m2), Some(m3)) => { - Err(ParserError::inputs_multiple_variable_types_specified(&(m1 + m2 + m3)).into()) + Err(ParserError::inputs_multiple_variable_types_specified(m1 + m2 + m3).into()) } } } @@ -90,7 +90,7 @@ impl ParserContext<'_> { let name = self.expect_ident()?; if let Some(mutable) = &mutable { - self.emit_err(ParserError::mut_function_input(&(mutable.span + name.span))); + self.emit_err(ParserError::mut_function_input(mutable.span + name.span)); } self.expect(&Token::Colon)?; diff --git a/compiler/parser/src/parser/input.rs b/compiler/parser/src/parser/input.rs index 5acf09ca61..1640ac42c4 100644 --- a/compiler/parser/src/parser/input.rs +++ b/compiler/parser/src/parser/input.rs @@ -27,7 +27,7 @@ impl ParserContext<'_> { if self.check(&Token::LeftSquare) { sections.push(self.parse_section()?); } else { - return Err(ParserError::unexpected_token(self.token.token.clone(), &self.token.span).into()); + return Err(ParserError::unexpected_token(self.token.token.clone(), self.token.span).into()); } } diff --git a/compiler/parser/src/parser/mod.rs b/compiler/parser/src/parser/mod.rs index a7cd4abfec..fc61c7bbd1 100644 --- a/compiler/parser/src/parser/mod.rs +++ b/compiler/parser/src/parser/mod.rs @@ -42,7 +42,7 @@ pub mod type_; pub(crate) fn assert_no_whitespace(left_span: Span, right_span: Span, left: &str, right: &str) -> Result<()> { if left_span.hi != right_span.lo { let error_span = Span::new(left_span.hi, right_span.lo); // The span between them. - return Err(ParserError::unexpected_whitespace(left, right, &error_span).into()); + return Err(ParserError::unexpected_whitespace(left, right, error_span).into()); } Ok(()) diff --git a/compiler/parser/src/parser/statement.rs b/compiler/parser/src/parser/statement.rs index c08cb1bdb0..b464bf21e2 100644 --- a/compiler/parser/src/parser/statement.rs +++ b/compiler/parser/src/parser/statement.rs @@ -27,7 +27,7 @@ impl ParserContext<'_> { pub fn construct_assignee_access(expr: Expression, _accesses: &mut [AssigneeAccess]) -> Result { match expr { Expression::Identifier(id) => Ok(id), - _ => Err(ParserError::invalid_assignment_target(&expr.span()).into()), + _ => Err(ParserError::invalid_assignment_target(expr.span()).into()), } } @@ -114,7 +114,7 @@ impl ParserContext<'_> { let next = if self.eat(&Token::Else) { let s = self.parse_statement()?; if !matches!(s, Statement::Block(_) | Statement::Conditional(_)) { - self.emit_err(ParserError::unexpected_statement(&s, "Block or Conditional", &s.span())); + self.emit_err(ParserError::unexpected_statement(&s, "Block or Conditional", s.span())); } Some(Box::new(s)) } else { @@ -168,7 +168,7 @@ impl ParserContext<'_> { string = Some(match token { Token::StringLit(chars) => chars, _ => { - p.emit_err(ParserError::unexpected_str(token, "formatted string", &span)); + p.emit_err(ParserError::unexpected_str(token, "formatted string", span)); Vec::new() } }); @@ -204,7 +204,7 @@ impl ParserContext<'_> { self.emit_err(ParserError::unexpected_ident( x, &["assert", "error", "log"], - &function.span, + function.span, )); ConsoleFunction::Log(self.parse_console_args()?) } @@ -219,9 +219,9 @@ impl ParserContext<'_> { /// Returns a [`VariableName`] AST node if the next tokens represent a variable name with /// valid keywords. - pub fn parse_variable_name(&mut self, decl_ty: Declare, span: &Span) -> Result { + pub fn parse_variable_name(&mut self, decl_ty: Declare, span: Span) -> Result { if self.eat(&Token::Mut) { - self.emit_err(ParserError::let_mut_statement(&(&self.prev_token.span + span))); + self.emit_err(ParserError::let_mut_statement(self.prev_token.span + span)); } let name = self.expect_ident()?; @@ -244,16 +244,16 @@ impl ParserContext<'_> { // Parse variable names. let variable_names = if self.peek_is_left_par() { let vars = self - .parse_paren_comma_list(|p| p.parse_variable_name(decl_type, &decl_span).map(Some)) + .parse_paren_comma_list(|p| p.parse_variable_name(decl_type, decl_span).map(Some)) .map(|(vars, ..)| vars)?; if vars.len() == 1 { - self.emit_err(ParserError::invalid_parens_around_single_variable(&vars[0].span())); + self.emit_err(ParserError::invalid_parens_around_single_variable(vars[0].span())); } vars } else { - vec![self.parse_variable_name(decl_type, &decl_span)?] + vec![self.parse_variable_name(decl_type, decl_span)?] }; self.expect(&Token::Colon)?; diff --git a/compiler/parser/src/tokenizer/mod.rs b/compiler/parser/src/tokenizer/mod.rs index 17c455433f..92ef2e59b4 100644 --- a/compiler/parser/src/tokenizer/mod.rs +++ b/compiler/parser/src/tokenizer/mod.rs @@ -58,7 +58,7 @@ pub(crate) fn tokenize_iter(input: &str, mut lo: BytePos) -> impl '_ + Iterator< match token { Token::WhiteSpace => continue, Token::AddressLit(address) if !check_address(&address) => { - return Some(Err(ParserError::invalid_address_lit(address, &span).into())); + return Some(Err(ParserError::invalid_address_lit(address, span).into())); } _ => return Some(Ok(SpannedToken { token, span })), } diff --git a/compiler/passes/src/symbol_table/table.rs b/compiler/passes/src/symbol_table/table.rs index 5c9df7b6ad..3ef4f45d4a 100644 --- a/compiler/passes/src/symbol_table/table.rs +++ b/compiler/passes/src/symbol_table/table.rs @@ -37,7 +37,7 @@ pub struct SymbolTable<'a> { impl<'a> SymbolTable<'a> { pub fn check_shadowing(&self, symbol: &Symbol) -> Result<()> { if let Some(function) = self.functions.get(symbol) { - Err(AstError::shadowed_function(symbol, &function.span).into()) + Err(AstError::shadowed_function(symbol, function.span).into()) } else { self.variables.check_shadowing(symbol)?; Ok(()) diff --git a/compiler/passes/src/symbol_table/variable_scope.rs b/compiler/passes/src/symbol_table/variable_scope.rs index d2b4693fdc..8d9cc98099 100644 --- a/compiler/passes/src/symbol_table/variable_scope.rs +++ b/compiler/passes/src/symbol_table/variable_scope.rs @@ -37,7 +37,7 @@ pub struct VariableScope<'a> { impl<'a> VariableScope<'a> { pub fn check_shadowing(&self, symbol: &Symbol) -> Result<()> { if let Some(var) = self.variables.get(symbol) { - Err(AstError::shadowed_variable(symbol, &var.span).into()) + Err(AstError::shadowed_variable(symbol, var.span).into()) } else if let Some(parent) = &self.parent { parent.check_shadowing(symbol) } else { diff --git a/compiler/passes/src/type_checker/check_expressions.rs b/compiler/passes/src/type_checker/check_expressions.rs index c6c1274556..1ae6d7bddf 100644 --- a/compiler/passes/src/type_checker/check_expressions.rs +++ b/compiler/passes/src/type_checker/check_expressions.rs @@ -46,7 +46,7 @@ impl<'a> TypeChecker<'a> { Some(self.assert_type(var.type_.clone(), expected, span)) } else { self.handler - .emit_err(TypeCheckerError::unknown_sym("variable", ident.name, &span).into()); + .emit_err(TypeCheckerError::unknown_sym("variable", ident.name, span).into()); None } } @@ -67,7 +67,7 @@ impl<'a> TypeChecker<'a> { if int.parse::().is_err() { self.handler - .emit_err(TypeCheckerError::invalid_int_value(int, "i8", &value.span()).into()); + .emit_err(TypeCheckerError::invalid_int_value(int, "i8", value.span()).into()); } } IntegerType::I16 => { @@ -80,7 +80,7 @@ impl<'a> TypeChecker<'a> { if int.parse::().is_err() { self.handler - .emit_err(TypeCheckerError::invalid_int_value(int, "i16", &value.span()).into()); + .emit_err(TypeCheckerError::invalid_int_value(int, "i16", value.span()).into()); } } IntegerType::I32 => { @@ -93,7 +93,7 @@ impl<'a> TypeChecker<'a> { if int.parse::().is_err() { self.handler - .emit_err(TypeCheckerError::invalid_int_value(int, "i32", &value.span()).into()); + .emit_err(TypeCheckerError::invalid_int_value(int, "i32", value.span()).into()); } } IntegerType::I64 => { @@ -106,7 +106,7 @@ impl<'a> TypeChecker<'a> { if int.parse::().is_err() { self.handler - .emit_err(TypeCheckerError::invalid_int_value(int, "i64", &value.span()).into()); + .emit_err(TypeCheckerError::invalid_int_value(int, "i64", value.span()).into()); } } IntegerType::I128 => { @@ -119,25 +119,25 @@ impl<'a> TypeChecker<'a> { if int.parse::().is_err() { self.handler - .emit_err(TypeCheckerError::invalid_int_value(int, "i128", &value.span()).into()); + .emit_err(TypeCheckerError::invalid_int_value(int, "i128", value.span()).into()); } } IntegerType::U8 if str_content.parse::().is_err() => self .handler - .emit_err(TypeCheckerError::invalid_int_value(str_content, "u8", &value.span()).into()), + .emit_err(TypeCheckerError::invalid_int_value(str_content, "u8", value.span()).into()), IntegerType::U16 if str_content.parse::().is_err() => self .handler - .emit_err(TypeCheckerError::invalid_int_value(str_content, "u16", &value.span()).into()), + .emit_err(TypeCheckerError::invalid_int_value(str_content, "u16", value.span()).into()), IntegerType::U32 if str_content.parse::().is_err() => self .handler - .emit_err(TypeCheckerError::invalid_int_value(str_content, "u32", &value.span()).into()), + .emit_err(TypeCheckerError::invalid_int_value(str_content, "u32", value.span()).into()), IntegerType::U64 if str_content.parse::().is_err() => self .handler - .emit_err(TypeCheckerError::invalid_int_value(str_content, "u64", &value.span()).into()), + .emit_err(TypeCheckerError::invalid_int_value(str_content, "u64", value.span()).into()), IntegerType::U128 if str_content.parse::().is_err() => self .handler - .emit_err(TypeCheckerError::invalid_int_value(str_content, "u128", &value.span()).into()), + .emit_err(TypeCheckerError::invalid_int_value(str_content, "u128", value.span()).into()), _ => {} } Some(self.assert_type(Type::IntegerType(*type_), expected, value.span())) @@ -195,7 +195,7 @@ impl<'a> TypeChecker<'a> { // But Type B was not a unsigned int. (Some(Type::IntegerType(_)), Some(t)) => { self.handler.emit_err( - TypeCheckerError::incorrect_pow_exponent_type("unsigned int", t, &binary.right.span()) + TypeCheckerError::incorrect_pow_exponent_type("unsigned int", t, binary.right.span()) .into(), ); } @@ -208,13 +208,13 @@ impl<'a> TypeChecker<'a> { // But Type B was not an int. (Some(Type::Field), Some(t)) => { self.handler.emit_err( - TypeCheckerError::incorrect_pow_exponent_type("int", t, &binary.right.span()).into(), + TypeCheckerError::incorrect_pow_exponent_type("int", t, binary.right.span()).into(), ); } // The base is some type thats not an int or field. (Some(t), _) => { self.handler - .emit_err(TypeCheckerError::incorrect_pow_base_type(t, &binary.left.span()).into()); + .emit_err(TypeCheckerError::incorrect_pow_base_type(t, binary.left.span()).into()); } _ => {} } @@ -261,7 +261,7 @@ impl<'a> TypeChecker<'a> { ) => self.negate = !self.negate, Some(t) => self .handler - .emit_err(TypeCheckerError::type_is_not_negatable(t, &unary.inner.span()).into()), + .emit_err(TypeCheckerError::type_is_not_negatable(t, unary.inner.span()).into()), _ => {} }; self.compare_expr_type(&unary.inner, expected, unary.inner.span()) @@ -283,7 +283,7 @@ impl<'a> TypeChecker<'a> { TypeCheckerError::incorrect_num_args_to_call( func.input.len(), call.arguments.len(), - &call.span(), + call.span(), ) .into(), ); @@ -303,7 +303,7 @@ impl<'a> TypeChecker<'a> { Some(ret) } else { self.handler - .emit_err(TypeCheckerError::unknown_sym("function", &ident.name, &ident.span()).into()); + .emit_err(TypeCheckerError::unknown_sym("function", &ident.name, ident.span()).into()); None } } diff --git a/compiler/passes/src/type_checker/check_statements.rs b/compiler/passes/src/type_checker/check_statements.rs index 218f4bec3d..52e9e19c15 100644 --- a/compiler/passes/src/type_checker/check_statements.rs +++ b/compiler/passes/src/type_checker/check_statements.rs @@ -63,17 +63,17 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { match &var.declaration { Declaration::Const => self .handler - .emit_err(TypeCheckerError::cannont_assign_to_const_var(var_name, &var.span).into()), + .emit_err(TypeCheckerError::cannont_assign_to_const_var(var_name, var.span).into()), Declaration::Input(ParamMode::Constant) => self .handler - .emit_err(TypeCheckerError::cannont_assign_to_const_input(var_name, &var.span).into()), + .emit_err(TypeCheckerError::cannont_assign_to_const_input(var_name, var.span).into()), _ => {} } Some(var.type_.clone()) } else { self.handler.emit_err( - TypeCheckerError::unknown_sym("variable", &input.assignee.identifier.name, &input.assignee.span).into(), + TypeCheckerError::unknown_sym("variable", &input.assignee.identifier.name, input.assignee.span).into(), ); None diff --git a/compiler/passes/src/type_checker/checker.rs b/compiler/passes/src/type_checker/checker.rs index fa6d02116b..212c3a9725 100644 --- a/compiler/passes/src/type_checker/checker.rs +++ b/compiler/passes/src/type_checker/checker.rs @@ -83,7 +83,7 @@ impl<'a> TypeChecker<'a> { if let Some(expected) = expected { if type_ != expected { self.handler - .emit_err(TypeCheckerError::type_should_be(type_.clone(), expected, &span).into()); + .emit_err(TypeCheckerError::type_should_be(type_.clone(), expected, span).into()); } } @@ -102,7 +102,7 @@ impl<'a> TypeChecker<'a> { TypeCheckerError::expected_one_type_of( expected.iter().map(|t| t.to_string() + ",").collect::(), type_, - &span, + span, ) .into(), ); diff --git a/leo/errors/src/common/macros.rs b/leo/errors/src/common/macros.rs index 608ed09aec..7654630452 100644 --- a/leo/errors/src/common/macros.rs +++ b/leo/errors/src/common/macros.rs @@ -96,7 +96,7 @@ macro_rules! create_messages { // Formatted errors always takes a span. $(#[$error_func_docs])* // Expands additional arguments for the error defining function. - pub fn $name($($arg_names: $arg_types,)* span: &leo_span::Span) -> Self { + pub fn $name($($arg_names: $arg_types,)* span: leo_span::Span) -> Self { Self::Formatted( Formatted::new_from_span( $message, @@ -105,7 +105,7 @@ macro_rules! create_messages { Self::code_identifier(), Self::message_type(), Self::is_error(), - *span, + span, // Each function always generates its own backtrace for backtrace clarity to originate from the error function. Backtrace::new(), ) diff --git a/leo/errors/src/emitter/mod.rs b/leo/errors/src/emitter/mod.rs index 28ee5d690e..4be8c4300c 100644 --- a/leo/errors/src/emitter/mod.rs +++ b/leo/errors/src/emitter/mod.rs @@ -282,19 +282,19 @@ mod tests { let res: Result<(), _> = Handler::with(|h| { let s = Span::default(); assert_eq!(h.err_count(), 0); - h.emit_err(ParserError::invalid_import_list(&s).into()); + h.emit_err(ParserError::invalid_import_list(s).into()); assert_eq!(h.err_count(), 1); - h.emit_err(ParserError::unexpected_eof(&s).into()); + h.emit_err(ParserError::unexpected_eof(s).into()); assert_eq!(h.err_count(), 2); - Err(ParserError::spread_in_array_init(&s).into()) + Err(ParserError::spread_in_array_init(s).into()) }); assert_eq!(count_err(res.unwrap_err().to_string()), 3); let res: Result<(), _> = Handler::with(|h| { let s = Span::default(); - h.emit_err(ParserError::invalid_import_list(&s).into()); - h.emit_err(ParserError::unexpected_eof(&s).into()); + h.emit_err(ParserError::invalid_import_list(s).into()); + h.emit_err(ParserError::unexpected_eof(s).into()); Ok(()) }); assert_eq!(count_err(res.unwrap_err().to_string()), 2);