@@ -160,13 +160,19 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
160160 }
161161 kind => ( kind, None , None ) ,
162162 } ;
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+ }
170176 } ;
171177 Ok ( ( Some ( PatRangeBoundary :: Finite ( value) ) , ascr, inline_const) )
172178 }
@@ -570,19 +576,13 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
570576 let args = self . typeck_results . node_args ( id) ;
571577 let c = ty:: Const :: new_unevaluated ( self . tcx , ty:: UnevaluatedConst { def : def_id, args } ) ;
572578 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+ // We only want to mark constants when referenced as bare names that could have been
580+ // new bindings if the `const` didn't exist.
581+ let pattern = Box :: new ( Pat {
582+ span,
583+ ty,
584+ kind : PatKind :: ExpandedConstant { subpattern, def_id, is_inline : false } ,
585+ } ) ;
586586
587587 if !is_associated_const {
588588 return pattern;
0 commit comments