diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index e9d4f4f..b548d42 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -936,14 +936,25 @@ impl Parser { ret } } - TokenKind::Function if matches!(self.peek.kind, TokenKind::Identifier(_) | TokenKind::Ampersand) => { + TokenKind::Function + if matches!( + self.peek.kind, + TokenKind::Identifier(_) | TokenKind::Ampersand + ) => + { // FIXME: This is incredibly hacky but we don't have a way to look at // the next N tokens right now. We could probably do with a `peek_buf()` // method like the Lexer has. if self.peek.kind == TokenKind::Ampersand { let mut cloned = self.iter.clone(); for (index, _) in self.iter.clone().enumerate() { - if ! matches!(cloned.nth(index), Some(Token { kind: TokenKind::Identifier(_), .. })) { + if !matches!( + cloned.nth(index), + Some(Token { + kind: TokenKind::Identifier(_), + .. + }) + ) { let expr = self.expression(Precedence::Lowest)?; self.semi()?; @@ -1405,14 +1416,14 @@ impl Parser { params, body, return_type, - by_ref + by_ref, } => Ok(Statement::Method { name, params, body, flags: vec![], return_type, - by_ref + by_ref, }), _ => unreachable!(), }, @@ -3881,60 +3892,66 @@ mod tests { #[test] fn function_returning_ref() { - assert_ast(" null;", &[ - expr!(Expression::ArrowFunction { + assert_ast( + " null;", + &[expr!(Expression::ArrowFunction { params: vec![], expr: Box::new(Expression::Null), return_type: None, by_ref: true, - }) - ]); + })], + ); } fn assert_ast(source: &str, expected: &[Statement]) {