1
Fork 0

Remove token::Lit from ast::MetaItemLit.

`token::Lit` contains a `kind` field that indicates what kind of literal
it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has
its own `kind` field. This means that `ast::MetaItemLit` encodes the
literal kind in two different ways.

This commit changes `ast::MetaItemLit` so it no longer wraps
`token::Lit`. It now contains the `symbol` and `suffix` fields from
`token::Lit`, but not the `kind` field, eliminating the redundancy.
This commit is contained in:
Nicholas Nethercote 2022-11-29 13:36:00 +11:00
parent a7f35c42d4
commit 2fd364acff
9 changed files with 56 additions and 23 deletions

View file

@ -420,7 +420,7 @@ impl<'a> Parser<'a> {
err.span_label(self_.token.span, format!("expected {}", expected));
err
});
PatKind::Lit(self.mk_expr(lo, ExprKind::Lit(lit.token_lit)))
PatKind::Lit(self.mk_expr(lo, ExprKind::Lit(lit.as_token_lit())))
} else {
// Try to parse everything else as literal with optional minus
match self.parse_literal_maybe_minus() {