@@ -182,7 +182,7 @@ use std::iter::once;
182182
183183use smallvec:: SmallVec ;
184184
185- use rustc_apfloat:: ieee:: { DoubleS , IeeeFloat , SingleS } ;
185+ use rustc_apfloat:: ieee:: { DoubleS , HalfS , IeeeFloat , QuadS , SingleS } ;
186186use rustc_index:: bit_set:: { BitSet , GrowableBitSet } ;
187187use rustc_index:: IndexVec ;
188188
@@ -692,8 +692,10 @@ pub enum Constructor<Cx: PatCx> {
692692 /// Ranges of integer literal values (`2`, `2..=5` or `2..5`).
693693 IntRange ( IntRange ) ,
694694 /// Ranges of floating-point literal values (`2.0..=5.2`).
695+ F16Range ( IeeeFloat < HalfS > , IeeeFloat < HalfS > , RangeEnd ) ,
695696 F32Range ( IeeeFloat < SingleS > , IeeeFloat < SingleS > , RangeEnd ) ,
696697 F64Range ( IeeeFloat < DoubleS > , IeeeFloat < DoubleS > , RangeEnd ) ,
698+ F128Range ( IeeeFloat < QuadS > , IeeeFloat < QuadS > , RangeEnd ) ,
697699 /// String literals. Strings are not quite the same as `&[u8]` so we treat them separately.
698700 Str ( Cx :: StrLit ) ,
699701 /// 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> {
735737 Constructor :: UnionField => Constructor :: UnionField ,
736738 Constructor :: Bool ( b) => Constructor :: Bool ( * b) ,
737739 Constructor :: IntRange ( range) => Constructor :: IntRange ( * range) ,
740+ Constructor :: F16Range ( lo, hi, end) => Constructor :: F16Range ( lo. clone ( ) , * hi, * end) ,
738741 Constructor :: F32Range ( lo, hi, end) => Constructor :: F32Range ( lo. clone ( ) , * hi, * end) ,
739742 Constructor :: F64Range ( lo, hi, end) => Constructor :: F64Range ( lo. clone ( ) , * hi, * end) ,
743+ Constructor :: F128Range ( lo, hi, end) => Constructor :: F128Range ( lo. clone ( ) , * hi, * end) ,
740744 Constructor :: Str ( value) => Constructor :: Str ( value. clone ( ) ) ,
741745 Constructor :: Opaque ( inner) => Constructor :: Opaque ( inner. clone ( ) ) ,
742746 Constructor :: Or => Constructor :: Or ,
@@ -812,6 +816,14 @@ impl<Cx: PatCx> Constructor<Cx> {
812816 ( Bool ( self_b) , Bool ( other_b) ) => self_b == other_b,
813817
814818 ( 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+ }
815827 ( F32Range ( self_from, self_to, self_end) , F32Range ( other_from, other_to, other_end) ) => {
816828 self_from. ge ( other_from)
817829 && match self_to. partial_cmp ( other_to) {
@@ -828,6 +840,17 @@ impl<Cx: PatCx> Constructor<Cx> {
828840 _ => false ,
829841 }
830842 }
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+ }
831854 ( Str ( self_val) , Str ( other_val) ) => {
832855 // FIXME Once valtrees are available we can directly use the bytes
833856 // in the `Str` variant of the valtree for the comparison here.
@@ -906,8 +929,10 @@ impl<Cx: PatCx> Constructor<Cx> {
906929 Bool ( b) => write ! ( f, "{b}" ) ?,
907930 // Best-effort, will render signed ranges incorrectly
908931 IntRange ( range) => write ! ( f, "{range:?}" ) ?,
932+ F16Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
909933 F32Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
910934 F64Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
935+ F128Range ( lo, hi, end) => write ! ( f, "{lo}{end}{hi}" ) ?,
911936 Str ( value) => write ! ( f, "{value:?}" ) ?,
912937 Opaque ( ..) => write ! ( f, "<constant pattern>" ) ?,
913938 Or => {
0 commit comments