diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-03-29 09:20:45 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-04-04 09:44:50 +0000 |
| commit | ec74653652e59fc209506c084357ccee922a2d73 (patch) | |
| tree | aa3b502664d0028db8443f96466d856942bc853a /compiler/rustc_parse/src/parser | |
| parent | e3828777a6b669c33fc59f2bddde44e888d304af (diff) | |
| download | rust-ec74653652e59fc209506c084357ccee922a2d73.tar.gz rust-ec74653652e59fc209506c084357ccee922a2d73.zip | |
Split out ast::ItemKind::Const into its own struct
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 60ecaf5cb22..f6422d30ba5 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -237,7 +237,7 @@ impl<'a> Parser<'a> { } else { self.recover_const_mut(const_span); let (ident, ty, expr) = self.parse_item_global(None)?; - (ident, ItemKind::Const(def_(), ty, expr)) + (ident, ItemKind::Const(ConstItem { defaultness: def_(), ty, expr })) } } else if self.check_keyword(kw::Trait) || self.check_auto_or_unsafe_trait_item() { // TRAIT ITEM @@ -863,9 +863,13 @@ impl<'a> Parser<'a> { let kind = match AssocItemKind::try_from(kind) { Ok(kind) => kind, Err(kind) => match kind { - ItemKind::Static(Static { ty: a, mutability: _, expr: b }) => { + ItemKind::Static(Static { ty, mutability: _, expr }) => { self.sess.emit_err(errors::AssociatedStaticItemNotAllowed { span }); - AssocItemKind::Const(Defaultness::Final, a, b) + AssocItemKind::Const(ConstItem { + defaultness: Defaultness::Final, + ty, + expr, + }) } _ => return self.error_bad_item_kind(span, &kind, "`trait`s or `impl`s"), }, @@ -1115,12 +1119,12 @@ impl<'a> Parser<'a> { let kind = match ForeignItemKind::try_from(kind) { Ok(kind) => kind, Err(kind) => match kind { - ItemKind::Const(_, a, b) => { + ItemKind::Const(ConstItem { ty, expr, .. }) => { self.sess.emit_err(errors::ExternItemCannotBeConst { ident_span: ident.span, const_span: span.with_hi(ident.span.lo()), }); - ForeignItemKind::Static(a, Mutability::Not, b) + ForeignItemKind::Static(ty, Mutability::Not, expr) } _ => return self.error_bad_item_kind(span, &kind, "`extern` blocks"), }, |
