diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-03-25 20:34:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-25 20:34:49 -0400 |
| commit | 5bd69d940e83db1971fbd1c5a999fdb308200cf7 (patch) | |
| tree | 51506c918572e6943a2cf05bb4b89a23f0ba8f9d /compiler/rustc_parse/src | |
| parent | f6bfdff86240e3af8f740e05b0ec04a4090139c5 (diff) | |
| parent | 0827f765864a17ac6354cc12ff353043cba62286 (diff) | |
| download | rust-5bd69d940e83db1971fbd1c5a999fdb308200cf7.tar.gz rust-5bd69d940e83db1971fbd1c5a999fdb308200cf7.zip | |
Rollup merge of #138911 - compiler-errors:define-opaque, r=oli-obk
Allow defining opaques in statics and consts r? oli-obk Fixes https://github.com/rust-lang/rust/issues/138902
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 123234fedce..c32a79f6909 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -265,6 +265,7 @@ impl<'a> Parser<'a> { generics, ty, expr, + define_opaque: None, })), ) } @@ -980,13 +981,20 @@ impl<'a> Parser<'a> { let kind = match AssocItemKind::try_from(kind) { Ok(kind) => kind, Err(kind) => match kind { - ItemKind::Static(box StaticItem { ty, safety: _, mutability: _, expr }) => { + ItemKind::Static(box StaticItem { + ty, + safety: _, + mutability: _, + expr, + define_opaque, + }) => { self.dcx().emit_err(errors::AssociatedStaticItemNotAllowed { span }); AssocItemKind::Const(Box::new(ConstItem { defaultness: Defaultness::Final, generics: Generics::default(), ty, expr, + define_opaque, })) } _ => return self.error_bad_item_kind(span, &kind, "`trait`s or `impl`s"), @@ -1254,6 +1262,7 @@ impl<'a> Parser<'a> { mutability: Mutability::Not, expr, safety: Safety::Default, + define_opaque: None, })) } _ => return self.error_bad_item_kind(span, &kind, "`extern` blocks"), @@ -1397,7 +1406,7 @@ impl<'a> Parser<'a> { self.expect_semi()?; - Ok((ident, StaticItem { ty, safety, mutability, expr })) + Ok((ident, StaticItem { ty, safety, mutability, expr, define_opaque: None })) } /// Parse a constant item with the prefix `"const"` already parsed. |
