@@ -160,13 +160,19 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
160
160
}
161
161
kind => (kind, None, None),
162
162
};
163
- let value = if let PatKind::Constant { value } = kind {
164
- value
165
- } else {
166
- let msg = format!(
167
- "found bad range pattern endpoint `{expr:?}` outside of error recovery"
168
- );
169
- return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg));
163
+ let value = match kind {
164
+ PatKind::Constant { value } => value,
165
+ PatKind::ExpandedConstant { subpattern, .. }
166
+ if let PatKind::Constant { value } = subpattern.kind =>
167
+ {
168
+ value
169
+ }
170
+ _ => {
171
+ let msg = format!(
172
+ "found bad range pattern endpoint `{expr:?}` outside of error recovery"
173
+ );
174
+ return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg));
175
+ }
170
176
};
171
177
Ok((Some(PatRangeBoundary::Finite(value)), ascr, inline_const))
172
178
}
@@ -570,19 +576,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
570
576
let args = self.typeck_results.node_args(id);
571
577
let c = ty::Const::new_unevaluated(self.tcx, ty::UnevaluatedConst { def: def_id, args });
572
578
let subpattern = self.const_to_pat(c, ty, id, span);
573
- let pattern = if let hir::QPath::Resolved(None, path) = qpath
574
- && path.segments.len() == 1
575
- {
576
- // We only want to mark constants when referenced as bare names that could have been
577
- // new bindings if the `const` didn't exist.
578
- Box::new(Pat {
579
- span,
580
- ty,
581
- kind: PatKind::ExpandedConstant { subpattern, def_id, is_inline: false },
582
- })
583
- } else {
584
- subpattern
585
- };
579
+ let pattern = Box::new(Pat {
580
+ span,
581
+ ty,
582
+ kind: PatKind::ExpandedConstant { subpattern, def_id, is_inline: false },
583
+ });
586
584
587
585
if !is_associated_const {
588
586
return pattern;
0 commit comments