diff --git a/huff_parser/src/lib.rs b/huff_parser/src/lib.rs index 22b122c5..c29fc5d1 100644 --- a/huff_parser/src/lib.rs +++ b/huff_parser/src/lib.rs @@ -104,7 +104,7 @@ impl Parser { TokenKind::Macro | TokenKind::Fn | TokenKind::Test => { let m = self.parse_macro()?; tracing::info!(target: "parser", "SUCCESSFULLY PARSED MACRO {}", m.name); - self.check_duplicate_macro(&mut contract, m.clone())?; + self.check_duplicate_macro(&contract, m.clone())?; contract.macros.push(m); } TokenKind::JumpTable | TokenKind::JumpTablePacked | TokenKind::CodeTable => { @@ -189,11 +189,11 @@ impl Parser { /// Checks if there is a duplicate macro name pub fn check_duplicate_macro( &self, - contract: &mut Contract, + contract: &Contract, m: MacroDefinition, ) -> Result<(), ParserError> { if contract.macros.binary_search_by(|_macro| _macro.name.cmp(&m.name)).is_ok() { - return Err(ParserError { + Err(ParserError { kind: ParserErrorKind::DuplicateMacro(m.name), hint: Some("MACRO names should be unique".to_string()), spans: AstSpan(vec![self.spans[2].clone()]), diff --git a/huff_parser/tests/macro.rs b/huff_parser/tests/macro.rs index 412d2136..6217eda2 100644 --- a/huff_parser/tests/macro.rs +++ b/huff_parser/tests/macro.rs @@ -1289,8 +1289,8 @@ fn test_duplicate_macro_error() { kind: ParserErrorKind::DuplicateMacro("MINT".to_string()), hint: Some("MACRO names should be unique".to_string()), spans: AstSpan(vec![Span { - start: occurrences[1].0.clone(), - end: occurrences[1].1.clone(), + start: occurrences[1].0, + end: occurrences[1].1, file: None }]), }