Skip to content

Commit 1801b2a

Browse files
Refactored code using maybe_parse
1 parent 157a992 commit 1801b2a

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/parser/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5210,12 +5210,9 @@ impl<'a> Parser<'a> {
52105210
// To check whether the first token is a name or a type, we need to
52115211
// peek the next token, which if it is another type keyword, then the
52125212
// first token is a name and not a type in itself.
5213-
let potential_tokens = [Token::Eq, Token::RParen, Token::Comma];
5214-
if !self.peek_keyword(Keyword::DEFAULT)
5215-
&& !potential_tokens.contains(&self.peek_token().token)
5216-
{
5213+
if let Some(next_data_type) = self.maybe_parse(|parser| parser.parse_data_type())? {
52175214
name = Some(Ident::new(next_token.to_string()));
5218-
data_type = self.parse_data_type()?;
5215+
data_type = next_data_type;
52195216
}
52205217

52215218
let default_expr = if self.parse_keyword(Keyword::DEFAULT) || self.consume_token(&Token::Eq)

0 commit comments

Comments
 (0)