diff options
| author | bors <bors@rust-lang.org> | 2023-04-04 16:39:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-04 16:39:26 +0000 |
| commit | 540a50df0fb23127edf0b35b0e497748e24bba1a (patch) | |
| tree | 3c9c994e0515892b6f6e112fc251edbb9986466a /compiler/rustc_parse/src/parser | |
| parent | be8e5ba157a4ae494f9b4219b3b848e44ea5e8d3 (diff) | |
| parent | 678d7c505d26a0e969c6a49e18a642f7d7de9a98 (diff) | |
| download | rust-540a50df0fb23127edf0b35b0e497748e24bba1a.tar.gz rust-540a50df0fb23127edf0b35b0e497748e24bba1a.zip | |
Auto merge of #109941 - compiler-errors:rollup-5lsst2u, r=compiler-errors
Rollup of 9 pull requests Successful merges: - #109723 (Pull some tuple variant fields out into their own struct) - #109838 (Fix `non_exhaustive_omitted_patterns` lint span) - #109901 (Enforce VarDebugInfo::Place in MIR validation.) - #109913 (Doc-comment `IndexVec::from_elem` and use it in a few more places) - #109914 (Emit feature error for parenthesized generics in associated type bounds) - #109919 (rustdoc: escape GAT args in more cases) - #109937 (Don't collect return-position impl traits for documentation) - #109938 (Move a const-prop-lint specific hack from mir interpret to const-prop-lint and make it fallible) - #109940 (Add regression test for #93911) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index ae8fe90e9d6..6422b8ac1ba 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -3,6 +3,7 @@ use crate::errors; use super::diagnostics::{dummy_arg, ConsumeClosingDelim}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken}; +use ast::StaticItem; use rustc_ast::ast::*; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, TokenKind}; @@ -227,7 +228,7 @@ impl<'a> Parser<'a> { self.bump(); // `static` let m = self.parse_mutability(); let (ident, ty, expr) = self.parse_item_global(Some(m))?; - (ident, ItemKind::Static(ty, m, expr)) + (ident, ItemKind::Static(Box::new(StaticItem { ty, mutability: m, expr }))) } else if let Const::Yes(const_span) = self.parse_constness(Case::Sensitive) { // CONST ITEM if self.token.is_keyword(kw::Impl) { @@ -236,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(Box::new(ConstItem { defaultness: def_(), ty, expr }))) } } else if self.check_keyword(kw::Trait) || self.check_auto_or_unsafe_trait_item() { // TRAIT ITEM @@ -862,9 +863,13 @@ impl<'a> Parser<'a> { let kind = match AssocItemKind::try_from(kind) { Ok(kind) => kind, Err(kind) => match kind { - ItemKind::Static(a, _, b) => { + ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => { self.sess.emit_err(errors::AssociatedStaticItemNotAllowed { span }); - AssocItemKind::Const(Defaultness::Final, a, b) + AssocItemKind::Const(Box::new(ConstItem { + defaultness: Defaultness::Final, + ty, + expr, + })) } _ => return self.error_bad_item_kind(span, &kind, "`trait`s or `impl`s"), }, @@ -1114,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(box 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"), }, |
