about summary refs log tree commit diff
path: root/compiler/rustc_ast/src/attr
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-11-29 13:36:00 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-12-02 13:49:19 +1100
commit2fd364acff5f962b0ce4f4dffb5ae085d5f2b67a (patch)
tree041c2e45d4449c44f874c737a3dcdbcaa8895c9f /compiler/rustc_ast/src/attr
parenta7f35c42d474f893c56b6e0f7df3f8bb965f2650 (diff)
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.
Diffstat (limited to 'compiler/rustc_ast/src/attr')
-rw-r--r--compiler/rustc_ast/src/attr/mod.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs
index 1ba46914675..2ec126715e7 100644
--- a/compiler/rustc_ast/src/attr/mod.rs
+++ b/compiler/rustc_ast/src/attr/mod.rs
@@ -328,7 +328,9 @@ pub fn mk_name_value_item_str(ident: Ident, str: Symbol, str_span: Span) -> Meta
 }
 
 pub fn mk_name_value_item(ident: Ident, kind: LitKind, lit_span: Span) -> MetaItem {
-    let lit = MetaItemLit { token_lit: kind.synthesize_token_lit(), kind, span: lit_span };
+    let token_lit = kind.synthesize_token_lit();
+    let lit =
+        MetaItemLit { symbol: token_lit.symbol, suffix: token_lit.suffix, kind, span: lit_span };
     let span = ident.span.to(lit_span);
     MetaItem { path: Path::from_ident(ident), kind: MetaItemKind::NameValue(lit), span }
 }