@@ -20,7 +20,7 @@ use rustc_middle::thir::{
2020use rustc_middle:: ty:: layout:: IntegerExt ;
2121use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty , TyCtxt , TypeVisitableExt } ;
2222use rustc_middle:: { bug, span_bug} ;
23- use rustc_span:: def_id:: LocalDefId ;
23+ use rustc_span:: def_id:: DefId ;
2424use rustc_span:: { ErrorGuaranteed , Span } ;
2525use tracing:: { debug, instrument} ;
2626
@@ -124,7 +124,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
124124 expr : Option < & ' tcx hir:: PatExpr < ' tcx > > ,
125125 // Out-parameters collecting extra data to be reapplied by the caller
126126 ascriptions : & mut Vec < Ascription < ' tcx > > ,
127- inline_consts : & mut Vec < LocalDefId > ,
127+ expanded_consts : & mut Vec < DefId > ,
128128 ) -> Result < Option < PatRangeBoundary < ' tcx > > , ErrorGuaranteed > {
129129 let Some ( expr) = expr else { return Ok ( None ) } ;
130130
@@ -139,10 +139,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
139139 ascriptions. push ( ascription) ;
140140 kind = subpattern. kind ;
141141 }
142- PatKind :: ExpandedConstant { is_inline, def_id, subpattern } => {
143- if is_inline {
144- inline_consts. extend ( def_id. as_local ( ) ) ;
145- }
142+ PatKind :: ExpandedConstant { def_id, subpattern } => {
143+ expanded_consts. push ( def_id) ;
146144 kind = subpattern. kind ;
147145 }
148146 _ => break ,
@@ -221,10 +219,10 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
221219
222220 // Collect extra data while lowering the endpoints, to be reapplied later.
223221 let mut ascriptions = vec ! [ ] ;
224- let mut inline_consts = vec ! [ ] ;
222+ let mut expanded_consts = vec ! [ ] ;
225223
226224 let mut lower_endpoint =
227- |expr| self . lower_pattern_range_endpoint ( expr, & mut ascriptions, & mut inline_consts ) ;
225+ |expr| self . lower_pattern_range_endpoint ( expr, & mut ascriptions, & mut expanded_consts ) ;
228226
229227 let lo = lower_endpoint ( lo_expr) ?. unwrap_or ( PatRangeBoundary :: NegInfinity ) ;
230228 let hi = lower_endpoint ( hi_expr) ?. unwrap_or ( PatRangeBoundary :: PosInfinity ) ;
@@ -269,17 +267,12 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
269267 // `Foo::<'a>::A..=Foo::B`), we need to put the ascriptions for the associated
270268 // constants somewhere. Have them on the range pattern.
271269 for ascription in ascriptions {
272- kind = PatKind :: AscribeUserType {
273- ascription,
274- subpattern : Box :: new ( Pat { span, ty, kind } ) ,
275- } ;
270+ let subpattern = Box :: new ( Pat { span, ty, kind } ) ;
271+ kind = PatKind :: AscribeUserType { ascription, subpattern } ;
276272 }
277- for def in inline_consts {
278- kind = PatKind :: ExpandedConstant {
279- def_id : def. to_def_id ( ) ,
280- is_inline : true ,
281- subpattern : Box :: new ( Pat { span, ty, kind } ) ,
282- } ;
273+ for def_id in expanded_consts {
274+ let subpattern = Box :: new ( Pat { span, ty, kind } ) ;
275+ kind = PatKind :: ExpandedConstant { def_id, subpattern } ;
283276 }
284277 Ok ( kind)
285278 }
0 commit comments