@@ -182,7 +182,7 @@ use std::iter::once;
182
182
183
183
use smallvec:: SmallVec ;
184
184
185
- use rustc_apfloat:: ieee:: { DoubleS , IeeeFloat , SingleS } ;
185
+ use rustc_apfloat:: ieee:: { DoubleS , HalfS , IeeeFloat , QuadS , SingleS } ;
186
186
use rustc_index:: bit_set:: { BitSet , GrowableBitSet } ;
187
187
use rustc_index:: IndexVec ;
188
188
@@ -692,8 +692,10 @@ pub enum Constructor<Cx: PatCx> {
692
692
/// Ranges of integer literal values (`2`, `2..=5` or `2..5`).
693
693
IntRange ( IntRange ) ,
694
694
/// Ranges of floating-point literal values (`2.0..=5.2`).
695
+ F16Range ( IeeeFloat < HalfS > , IeeeFloat < HalfS > , RangeEnd ) ,
695
696
F32Range ( IeeeFloat < SingleS > , IeeeFloat < SingleS > , RangeEnd ) ,
696
697
F64Range ( IeeeFloat < DoubleS > , IeeeFloat < DoubleS > , RangeEnd ) ,
698
+ F128Range ( IeeeFloat < QuadS > , IeeeFloat < QuadS > , RangeEnd ) ,
697
699
/// String literals. Strings are not quite the same as `&[u8]` so we treat them separately.
698
700
Str ( Cx :: StrLit ) ,
699
701
/// Constants that must not be matched structurally. They are treated as black boxes for the
@@ -735,8 +737,10 @@ impl<Cx: PatCx> Clone for Constructor<Cx> {
735
737
Constructor :: UnionField => Constructor :: UnionField ,
736
738
Constructor :: Bool ( b) => Constructor :: Bool ( * b) ,
737
739
Constructor :: IntRange ( range) => Constructor :: IntRange ( * range) ,
740
+ Constructor :: F16Range ( lo, hi, end) => Constructor :: F16Range ( lo. clone ( ) , * hi, * end) ,
738
741
Constructor :: F32Range ( lo, hi, end) => Constructor :: F32Range ( lo. clone ( ) , * hi, * end) ,
739
742
Constructor :: F64Range ( lo, hi, end) => Constructor :: F64Range ( lo. clone ( ) , * hi, * end) ,
743
+ Constructor :: F128Range ( lo, hi, end) => Constructor :: F128Range ( lo. clone ( ) , * hi, * end) ,
740
744
Constructor :: Str ( value) => Constructor :: Str ( value. clone ( ) ) ,
741
745
Constructor :: Opaque ( inner) => Constructor :: Opaque ( inner. clone ( ) ) ,
742
746
Constructor :: Or => Constructor :: Or ,
@@ -812,6 +816,14 @@ impl<Cx: PatCx> Constructor<Cx> {
812
816
( Bool ( self_b) , Bool ( other_b) ) => self_b == other_b,
813
817
814
818
( IntRange ( self_range) , IntRange ( other_range) ) => self_range. is_subrange ( other_range) ,
819
+ ( F16Range ( self_from, self_to, self_end) , F16Range ( other_from, other_to, other_end) ) => {
820
+ self_from. ge ( other_from)
821
+ && match self_to. partial_cmp ( other_to) {
822
+ Some ( Ordering :: Less ) => true ,
823
+ Some ( Ordering :: Equal ) => other_end == self_end,
824
+ _ => false ,
825
+ }
826
+ }
815
827
( F32Range ( self_from, self_to, self_end) , F32Range ( other_from, other_to, other_end) ) => {
816
828
self_from. ge ( other_from)
817
829
&& match self_to. partial_cmp ( other_to) {
@@ -828,6 +840,17 @@ impl<Cx: PatCx> Constructor<Cx> {
828
840
_ => false ,
829
841
}
830
842
}
843
+ (
844
+ F128Range ( self_from, self_to, self_end) ,
845
+ F128Range ( other_from, other_to, other_end) ,
846
+ ) => {
847
+ self_from. ge ( other_from)
848
+ && match self_to. partial_cmp ( other_to) {
849
+ Some ( Ordering :: Less ) => true ,
850
+ Some ( Ordering :: Equal ) => other_end == self_end,
851
+ _ => false ,
852
+ }
853
+ }
831
854
( Str ( self_val) , Str ( other_val) ) => {
832
855
// FIXME Once valtrees are available we can directly use the bytes
833
856
// in the `Str` variant of the valtree for the comparison here.
@@ -906,8 +929,10 @@ impl<Cx: PatCx> Constructor<Cx> {
906
929
Bool ( b) => write ! ( f, "{b}" ) ?,
907
930
// Best-effort, will render signed ranges incorrectly
908
931
IntRange ( range) => write ! ( f, "{range:?}" ) ?,
932
+ F16Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
909
933
F32Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
910
934
F64Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
935
+ F128Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
911
936
Str ( value) => write ! ( f, "{value:?}" ) ?,
912
937
Opaque ( ..) => write ! ( f, "<constant pattern>" ) ?,
913
938
Or => {
0 commit comments