@@ -957,9 +957,9 @@ impl<'tcx> PatRange<'tcx> {
957957 #[ inline]
958958 pub fn contains ( & self , value : ty:: Value < ' tcx > , tcx : TyCtxt < ' tcx > ) -> Option < bool > {
959959 use Ordering :: * ;
960- debug_assert_eq ! ( self . ty, value . ty) ;
960+ debug_assert_eq ! ( value . ty, self . ty) ;
961961 let ty = self . ty ;
962- let value = PatRangeBoundary :: Finite ( value) ;
962+ let value = PatRangeBoundary :: Finite ( value. valtree ) ;
963963 // For performance, it's important to only do the second comparison if necessary.
964964 Some (
965965 match self . lo . compare_with ( value, ty, tcx) ? {
@@ -994,11 +994,13 @@ impl<'tcx> PatRange<'tcx> {
994994
995995impl < ' tcx > fmt:: Display for PatRange < ' tcx > {
996996 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
997- if let PatRangeBoundary :: Finite ( value) = & self . lo {
997+ if let & PatRangeBoundary :: Finite ( valtree) = & self . lo {
998+ let value = ty:: Value { ty : self . ty , valtree } ;
998999 write ! ( f, "{value}" ) ?;
9991000 }
1000- if let PatRangeBoundary :: Finite ( value ) = & self . hi {
1001+ if let & PatRangeBoundary :: Finite ( valtree ) = & self . hi {
10011002 write ! ( f, "{}" , self . end) ?;
1003+ let value = ty:: Value { ty : self . ty , valtree } ;
10021004 write ! ( f, "{value}" ) ?;
10031005 } else {
10041006 // `0..` is parsed as an inclusive range, we must display it correctly.
@@ -1012,7 +1014,8 @@ impl<'tcx> fmt::Display for PatRange<'tcx> {
10121014/// If present, the const must be of a numeric type.
10131015#[ derive( Copy , Clone , Debug , PartialEq , HashStable , TypeVisitable ) ]
10141016pub enum PatRangeBoundary < ' tcx > {
1015- Finite ( ty:: Value < ' tcx > ) ,
1017+ /// The type of this valtree is stored in the surrounding `PatRange`.
1018+ Finite ( ty:: ValTree < ' tcx > ) ,
10161019 NegInfinity ,
10171020 PosInfinity ,
10181021}
@@ -1023,7 +1026,7 @@ impl<'tcx> PatRangeBoundary<'tcx> {
10231026 matches ! ( self , Self :: Finite ( ..) )
10241027 }
10251028 #[ inline]
1026- pub fn as_finite ( self ) -> Option < ty:: Value < ' tcx > > {
1029+ pub fn as_finite ( self ) -> Option < ty:: ValTree < ' tcx > > {
10271030 match self {
10281031 Self :: Finite ( value) => Some ( value) ,
10291032 Self :: NegInfinity | Self :: PosInfinity => None ,
0 commit comments