@@ -959,9 +959,9 @@ impl<'tcx> PatRange<'tcx> {
959959 #[ inline]
960960 pub fn contains ( & self , value : ty:: Value < ' tcx > , tcx : TyCtxt < ' tcx > ) -> Option < bool > {
961961 use Ordering :: * ;
962- debug_assert_eq ! ( self . ty, value . ty) ;
962+ debug_assert_eq ! ( value . ty, self . ty) ;
963963 let ty = self . ty ;
964- let value = PatRangeBoundary :: Finite ( value) ;
964+ let value = PatRangeBoundary :: Finite ( value. valtree ) ;
965965 // For performance, it's important to only do the second comparison if necessary.
966966 Some (
967967 match self . lo . compare_with ( value, ty, tcx) ? {
@@ -996,11 +996,13 @@ impl<'tcx> PatRange<'tcx> {
996996
997997impl < ' tcx > fmt:: Display for PatRange < ' tcx > {
998998 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 } ;
10001001 write ! ( f, "{value}" ) ?;
10011002 }
1002- if let PatRangeBoundary :: Finite ( value ) = & self . hi {
1003+ if let & PatRangeBoundary :: Finite ( valtree ) = & self . hi {
10031004 write ! ( f, "{}" , self . end) ?;
1005+ let value = ty:: Value { ty : self . ty , valtree } ;
10041006 write ! ( f, "{value}" ) ?;
10051007 } else {
10061008 // `0..` is parsed as an inclusive range, we must display it correctly.
@@ -1014,7 +1016,8 @@ impl<'tcx> fmt::Display for PatRange<'tcx> {
10141016/// If present, the const must be of a numeric type.
10151017#[ derive( Copy , Clone , Debug , PartialEq , HashStable , TypeVisitable ) ]
10161018pub 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 > ) ,
10181021 NegInfinity ,
10191022 PosInfinity ,
10201023}
@@ -1025,7 +1028,7 @@ impl<'tcx> PatRangeBoundary<'tcx> {
10251028 matches ! ( self , Self :: Finite ( ..) )
10261029 }
10271030 #[ inline]
1028- pub fn as_finite ( self ) -> Option < ty:: Value < ' tcx > > {
1031+ pub fn as_finite ( self ) -> Option < ty:: ValTree < ' tcx > > {
10291032 match self {
10301033 Self :: Finite ( value) => Some ( value) ,
10311034 Self :: NegInfinity | Self :: PosInfinity => None ,
0 commit comments