@@ -959,9 +959,9 @@ impl<'tcx> PatRange<'tcx> {
959
959
#[ inline]
960
960
pub fn contains ( & self , value : ty:: Value < ' tcx > , tcx : TyCtxt < ' tcx > ) -> Option < bool > {
961
961
use Ordering :: * ;
962
- debug_assert_eq ! ( self . ty, value . ty) ;
962
+ debug_assert_eq ! ( value . ty, self . ty) ;
963
963
let ty = self . ty ;
964
- let value = PatRangeBoundary :: Finite ( value) ;
964
+ let value = PatRangeBoundary :: Finite ( value. valtree ) ;
965
965
// For performance, it's important to only do the second comparison if necessary.
966
966
Some (
967
967
match self . lo . compare_with ( value, ty, tcx) ? {
@@ -996,11 +996,13 @@ impl<'tcx> PatRange<'tcx> {
996
996
997
997
impl < ' tcx > fmt:: Display for PatRange < ' tcx > {
998
998
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
999
- if let PatRangeBoundary :: Finite ( value) = & self . lo {
999
+ if let & PatRangeBoundary :: Finite ( valtree) = & self . lo {
1000
+ let value = ty:: Value { ty : self . ty , valtree } ;
1000
1001
write ! ( f, "{value}" ) ?;
1001
1002
}
1002
- if let PatRangeBoundary :: Finite ( value ) = & self . hi {
1003
+ if let & PatRangeBoundary :: Finite ( valtree ) = & self . hi {
1003
1004
write ! ( f, "{}" , self . end) ?;
1005
+ let value = ty:: Value { ty : self . ty , valtree } ;
1004
1006
write ! ( f, "{value}" ) ?;
1005
1007
} else {
1006
1008
// `0..` is parsed as an inclusive range, we must display it correctly.
@@ -1014,7 +1016,8 @@ impl<'tcx> fmt::Display for PatRange<'tcx> {
1014
1016
/// If present, the const must be of a numeric type.
1015
1017
#[ derive( Copy , Clone , Debug , PartialEq , HashStable , TypeVisitable ) ]
1016
1018
pub enum PatRangeBoundary < ' tcx > {
1017
- Finite ( ty:: Value < ' tcx > ) ,
1019
+ /// The type of this valtree is stored in the surrounding `PatRange`.
1020
+ Finite ( ty:: ValTree < ' tcx > ) ,
1018
1021
NegInfinity ,
1019
1022
PosInfinity ,
1020
1023
}
@@ -1025,7 +1028,7 @@ impl<'tcx> PatRangeBoundary<'tcx> {
1025
1028
matches ! ( self , Self :: Finite ( ..) )
1026
1029
}
1027
1030
#[ inline]
1028
- pub fn as_finite ( self ) -> Option < ty:: Value < ' tcx > > {
1031
+ pub fn as_finite ( self ) -> Option < ty:: ValTree < ' tcx > > {
1029
1032
match self {
1030
1033
Self :: Finite ( value) => Some ( value) ,
1031
1034
Self :: NegInfinity | Self :: PosInfinity => None ,
0 commit comments