@@ -246,8 +246,9 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
246246 }
247247 _ => bug ! ( "bad slice pattern {:?} {:?}" , ctor, ty) ,
248248 } ,
249- Bool ( ..) | IntRange ( ..) | F32Range ( ..) | F64Range ( ..) | Str ( ..) | Opaque ( ..)
250- | Never | NonExhaustive | Hidden | Missing | PrivateUninhabited | Wildcard => & [ ] ,
249+ Bool ( ..) | IntRange ( ..) | F16Range ( ..) | F32Range ( ..) | F64Range ( ..)
250+ | F128Range ( ..) | Str ( ..) | Opaque ( ..) | Never | NonExhaustive | Hidden | Missing
251+ | PrivateUninhabited | Wildcard => & [ ] ,
251252 Or => {
252253 bug ! ( "called `Fields::wildcards` on an `Or` ctor" )
253254 }
@@ -274,8 +275,9 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
274275 } ,
275276 Ref => 1 ,
276277 Slice ( slice) => slice. arity ( ) ,
277- Bool ( ..) | IntRange ( ..) | F32Range ( ..) | F64Range ( ..) | Str ( ..) | Opaque ( ..)
278- | Never | NonExhaustive | Hidden | Missing | PrivateUninhabited | Wildcard => 0 ,
278+ Bool ( ..) | IntRange ( ..) | F16Range ( ..) | F32Range ( ..) | F64Range ( ..)
279+ | F128Range ( ..) | Str ( ..) | Opaque ( ..) | Never | NonExhaustive | Hidden | Missing
280+ | PrivateUninhabited | Wildcard => 0 ,
279281 Or => bug ! ( "The `Or` constructor doesn't have a fixed arity" ) ,
280282 }
281283 }
@@ -545,6 +547,18 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
545547 fields = vec ! [ ] ;
546548 arity = 0 ;
547549 }
550+ ty:: Float ( ty:: FloatTy :: F16 ) => {
551+ ctor = match value. try_eval_bits ( cx. tcx , cx. param_env ) {
552+ Some ( bits) => {
553+ use rustc_apfloat:: Float ;
554+ let value = rustc_apfloat:: ieee:: Half :: from_bits ( bits) ;
555+ F16Range ( value, value, RangeEnd :: Included )
556+ }
557+ None => Opaque ( OpaqueId :: new ( ) ) ,
558+ } ;
559+ fields = vec ! [ ] ;
560+ arity = 0 ;
561+ }
548562 ty:: Float ( ty:: FloatTy :: F32 ) => {
549563 ctor = match value. try_eval_bits ( cx. tcx , cx. param_env ) {
550564 Some ( bits) => {
@@ -569,6 +583,18 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
569583 fields = vec ! [ ] ;
570584 arity = 0 ;
571585 }
586+ ty:: Float ( ty:: FloatTy :: F128 ) => {
587+ ctor = match value. try_eval_bits ( cx. tcx , cx. param_env ) {
588+ Some ( bits) => {
589+ use rustc_apfloat:: Float ;
590+ let value = rustc_apfloat:: ieee:: Quad :: from_bits ( bits) ;
591+ F128Range ( value, value, RangeEnd :: Included )
592+ }
593+ None => Opaque ( OpaqueId :: new ( ) ) ,
594+ } ;
595+ fields = vec ! [ ] ;
596+ arity = 0 ;
597+ }
572598 ty:: Ref ( _, t, _) if t. is_str ( ) => {
573599 // We want a `&str` constant to behave like a `Deref` pattern, to be compatible
574600 // with other `Deref` patterns. This could have been done in `const_to_pat`,
@@ -610,7 +636,12 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
610636 let lo = lo. as_finite ( ) . map ( |c| c. eval_bits ( cx. tcx , cx. param_env ) ) ;
611637 let hi = hi. as_finite ( ) . map ( |c| c. eval_bits ( cx. tcx , cx. param_env ) ) ;
612638 match fty {
613- ty:: FloatTy :: F16 => unimplemented ! ( "f16_f128" ) ,
639+ ty:: FloatTy :: F16 => {
640+ use rustc_apfloat:: ieee:: Half ;
641+ let lo = lo. map ( Half :: from_bits) . unwrap_or ( -Half :: INFINITY ) ;
642+ let hi = hi. map ( Half :: from_bits) . unwrap_or ( Half :: INFINITY ) ;
643+ F16Range ( lo, hi, end)
644+ }
614645 ty:: FloatTy :: F32 => {
615646 use rustc_apfloat:: ieee:: Single ;
616647 let lo = lo. map ( Single :: from_bits) . unwrap_or ( -Single :: INFINITY ) ;
@@ -623,7 +654,12 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
623654 let hi = hi. map ( Double :: from_bits) . unwrap_or ( Double :: INFINITY ) ;
624655 F64Range ( lo, hi, end)
625656 }
626- ty:: FloatTy :: F128 => unimplemented ! ( "f16_f128" ) ,
657+ ty:: FloatTy :: F128 => {
658+ use rustc_apfloat:: ieee:: Quad ;
659+ let lo = lo. map ( Quad :: from_bits) . unwrap_or ( -Quad :: INFINITY ) ;
660+ let hi = hi. map ( Quad :: from_bits) . unwrap_or ( Quad :: INFINITY ) ;
661+ F128Range ( lo, hi, end)
662+ }
627663 }
628664 }
629665 _ => bug ! ( "invalid type for range pattern: {}" , ty. inner( ) ) ,
@@ -836,7 +872,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
836872 "trying to convert a `Missing` constructor into a `Pat`; this is probably a bug,
837873 `Missing` should have been processed in `apply_constructors`"
838874 ) ,
839- F32Range ( ..) | F64Range ( ..) | Opaque ( ..) | Or => {
875+ F16Range ( .. ) | F32Range ( ..) | F64Range ( .. ) | F128Range ( ..) | Opaque ( ..) | Or => {
840876 bug ! ( "can't convert to pattern: {:?}" , pat)
841877 }
842878 } ;
0 commit comments