@@ -337,6 +337,20 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
337
337
_ => false ,
338
338
}
339
339
}
340
+
341
+ fn pat_is_poly ( & mut self , pat : & thir:: Pat < ' tcx > ) -> bool {
342
+ if pat. ty . has_param_types_or_consts ( ) {
343
+ return true ;
344
+ }
345
+
346
+ match pat. kind . as_ref ( ) {
347
+ thir:: PatKind :: Constant { value } => value. has_param_types_or_consts ( ) ,
348
+ thir:: PatKind :: Range ( thir:: PatRange { lo, hi, .. } ) => {
349
+ lo. has_param_types_or_consts ( ) || hi. has_param_types_or_consts ( )
350
+ }
351
+ _ => false ,
352
+ }
353
+ }
340
354
}
341
355
342
356
impl < ' a , ' tcx > visit:: Visitor < ' a , ' tcx > for IsThirPolymorphic < ' a , ' tcx > {
@@ -354,18 +368,9 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
354
368
355
369
#[ instrument( skip( self ) , level = "debug" ) ]
356
370
fn visit_pat ( & mut self , pat : & thir:: Pat < ' tcx > ) {
357
- self . is_poly |= pat . ty . has_param_types_or_consts ( ) ;
371
+ self . is_poly |= self . pat_is_poly ( pat ) ;
358
372
if !self . is_poly {
359
- match pat. kind . as_ref ( ) {
360
- thir:: PatKind :: Constant { value } => {
361
- self . is_poly |= value. has_param_types_or_consts ( ) ;
362
- }
363
- thir:: PatKind :: Range ( thir:: PatRange { lo, hi, .. } ) => {
364
- self . is_poly |=
365
- lo. has_param_types_or_consts ( ) | hi. has_param_types_or_consts ( ) ;
366
- }
367
- _ => visit:: walk_pat ( self , pat) ,
368
- }
373
+ visit:: walk_pat ( self , pat) ;
369
374
}
370
375
}
371
376
}
@@ -443,7 +448,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
443
448
444
449
self . nodes . push ( Node :: Leaf ( constant) )
445
450
}
446
- & ExprKind :: ScalarLiteral { lit , user_ty : _} => {
451
+ & ExprKind :: NonHirLiteral { lit , user_ty : _} => {
447
452
// FIXME Construct a Valtree from this ScalarInt when introducing Valtrees
448
453
let const_value = ConstValue :: Scalar ( Scalar :: Int ( lit) ) ;
449
454
self . nodes . push ( Node :: Leaf ( ty:: Const :: from_value ( self . tcx , const_value, node. ty ) ) )
0 commit comments