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