Skip to content

Commit 29acf8b

Browse files
committed
Account for ExpandedConstant in parse_match
1 parent 912ee65 commit 29acf8b

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

compiler/rustc_mir_build/src/build/custom/parse/instruction.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,20 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
144144
let mut targets = Vec::new();
145145
for arm in rest {
146146
let arm = &self.thir[*arm];
147-
let PatKind::Constant { value } = arm.pattern.kind else {
148-
return Err(ParseError {
149-
span: arm.pattern.span,
150-
item_description: format!("{:?}", arm.pattern.kind),
151-
expected: "constant pattern".to_string(),
152-
});
147+
let value = match arm.pattern.kind {
148+
PatKind::Constant { value } => value,
149+
PatKind::ExpandedConstant { ref subpattern, def_id: _, is_inline: false }
150+
if let PatKind::Constant { value } = subpattern.kind =>
151+
{
152+
value
153+
}
154+
_ => {
155+
return Err(ParseError {
156+
span: arm.pattern.span,
157+
item_description: format!("{:?}", arm.pattern.kind),
158+
expected: "constant pattern".to_string(),
159+
});
160+
}
153161
};
154162
values.push(value.eval_bits(self.tcx, self.param_env));
155163
targets.push(self.parse_block(arm.body)?);

0 commit comments

Comments
 (0)