@@ -461,33 +461,36 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
461
461
. collect ( )
462
462
}
463
463
ty:: TyChar if exhaustive_integer_patterns => {
464
+ value_constructors = true ;
464
465
let endpoint = |c : char | {
465
- ty:: Const :: from_bits ( cx. tcx , c as u128 , cx. tcx . types . char )
466
+ let ty = ty:: ParamEnv :: empty ( ) . and ( cx. tcx . types . char ) ;
467
+ ty:: Const :: from_bits ( cx. tcx , c as u128 , ty)
466
468
} ;
467
- value_constructors = true ;
468
469
vec ! [
469
470
// The valid Unicode Scalar Value ranges.
470
471
ConstantRange ( endpoint( '\u{0000}' ) , endpoint( '\u{D7FF}' ) , RangeEnd :: Included ) ,
471
472
ConstantRange ( endpoint( '\u{E000}' ) , endpoint( '\u{10FFFF}' ) , RangeEnd :: Included ) ,
472
473
]
473
474
}
474
475
ty:: TyInt ( ity) if exhaustive_integer_patterns => {
476
+ value_constructors = true ;
475
477
// FIXME(49937): refactor these bit manipulations into interpret.
476
478
let bits = Integer :: from_attr ( cx. tcx , SignedInt ( ity) ) . size ( ) . bits ( ) as u128 ;
477
479
let min = 1u128 << ( bits - 1 ) ;
478
480
let max = ( 1u128 << ( bits - 1 ) ) - 1 ;
479
- value_constructors = true ;
480
- vec ! [ ConstantRange ( ty:: Const :: from_bits( cx. tcx, min as u128 , pcx . ty) ,
481
- ty:: Const :: from_bits( cx. tcx, max as u128 , pcx . ty) ,
481
+ let ty = ty :: ParamEnv :: empty ( ) . and ( pcx . ty ) ;
482
+ vec ! [ ConstantRange ( ty:: Const :: from_bits( cx. tcx, min as u128 , ty) ,
483
+ ty:: Const :: from_bits( cx. tcx, max as u128 , ty) ,
482
484
RangeEnd :: Included ) ]
483
485
}
484
486
ty:: TyUint ( uty) if exhaustive_integer_patterns => {
487
+ value_constructors = true ;
485
488
// FIXME(49937): refactor these bit manipulations into interpret.
486
489
let bits = Integer :: from_attr ( cx. tcx , UnsignedInt ( uty) ) . size ( ) . bits ( ) as u128 ;
487
490
let max = !0u128 >> ( 128 - bits) ;
488
- value_constructors = true ;
489
- vec ! [ ConstantRange ( ty:: Const :: from_bits( cx. tcx, 0 , pcx . ty) ,
490
- ty:: Const :: from_bits( cx. tcx, max, pcx . ty) ,
491
+ let ty = ty :: ParamEnv :: empty ( ) . and ( pcx . ty ) ;
492
+ vec ! [ ConstantRange ( ty:: Const :: from_bits( cx. tcx, 0 , ty) ,
493
+ ty:: Const :: from_bits( cx. tcx, max, ty) ,
491
494
RangeEnd :: Included ) ]
492
495
}
493
496
_ => {
@@ -623,8 +626,9 @@ impl<'tcx> IntRange<'tcx> {
623
626
ConstantRange ( lo, hi, end) => {
624
627
assert_eq ! ( lo. ty, hi. ty) ;
625
628
let ty = lo. ty ;
626
- if let Some ( lo) = lo. assert_bits ( ty) {
627
- if let Some ( hi) = hi. assert_bits ( ty) {
629
+ let env_ty = ty:: ParamEnv :: empty ( ) . and ( ty) ;
630
+ if let Some ( lo) = lo. assert_bits ( tcx, env_ty) {
631
+ if let Some ( hi) = hi. assert_bits ( tcx, env_ty) {
628
632
// Perform a shift if the underlying types are signed,
629
633
// which makes the interval arithmetic simpler.
630
634
let bias = IntRange :: signed_bias ( tcx, ty) ;
@@ -642,7 +646,7 @@ impl<'tcx> IntRange<'tcx> {
642
646
}
643
647
ConstantValue ( val) => {
644
648
let ty = val. ty ;
645
- if let Some ( val) = val. assert_bits ( ty ) {
649
+ if let Some ( val) = val. assert_bits ( tcx , ty :: ParamEnv :: empty ( ) . and ( ty ) ) {
646
650
let bias = IntRange :: signed_bias ( tcx, ty) ;
647
651
let val = val ^ bias;
648
652
Some ( IntRange { range : val..=val, ty } )
@@ -707,6 +711,7 @@ fn ranges_subtract_pattern<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
707
711
remaining_ranges. into_iter ( ) . map ( |r| {
708
712
let ( lo, hi) = r. into_inner ( ) ;
709
713
let bias = IntRange :: signed_bias ( cx. tcx , ty) ;
714
+ let ty = ty:: ParamEnv :: empty ( ) . and ( ty) ;
710
715
ConstantRange ( ty:: Const :: from_bits ( cx. tcx , lo ^ bias, ty) ,
711
716
ty:: Const :: from_bits ( cx. tcx , hi ^ bias, ty) ,
712
717
RangeEnd :: Included )
0 commit comments