about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-11-17 23:58:22 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-11-17 23:58:22 +0000
commit29acf8b422ab446fa4cd51fbb0e5a145f30c1cfc (patch)
tree58e50fee82d186c5335cd39a2e06e805ee240923
parent912ee65ccdad256c855a2ae67925ca7efd2eee99 (diff)
downloadrust-29acf8b422ab446fa4cd51fbb0e5a145f30c1cfc.tar.gz
rust-29acf8b422ab446fa4cd51fbb0e5a145f30c1cfc.zip
Account for `ExpandedConstant` in `parse_match`
-rw-r--r--compiler/rustc_mir_build/src/build/custom/parse/instruction.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs
index 07964e304b9..62d173987fc 100644
--- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs
+++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs
@@ -144,12 +144,20 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
         let mut targets = Vec::new();
         for arm in rest {
             let arm = &self.thir[*arm];
-            let PatKind::Constant { value } = arm.pattern.kind else {
-                return Err(ParseError {
-                    span: arm.pattern.span,
-                    item_description: format!("{:?}", arm.pattern.kind),
-                    expected: "constant pattern".to_string(),
-                });
+            let value = match arm.pattern.kind {
+                PatKind::Constant { value } => value,
+                PatKind::ExpandedConstant { ref subpattern, def_id: _, is_inline: false }
+                    if let PatKind::Constant { value } = subpattern.kind =>
+                {
+                    value
+                }
+                _ => {
+                    return Err(ParseError {
+                        span: arm.pattern.span,
+                        item_description: format!("{:?}", arm.pattern.kind),
+                        expected: "constant pattern".to_string(),
+                    });
+                }
             };
             values.push(value.eval_bits(self.tcx, self.param_env));
             targets.push(self.parse_block(arm.body)?);