@@ -21,6 +21,7 @@ use rustc_middle::ty::{
2121 self , CanonicalUserTypeAnnotation , Ty , TypeVisitableExt , ValTree , ValTreeKind ,
2222} ;
2323use rustc_middle:: { bug, span_bug} ;
24+ use rustc_pattern_analysis:: constructor:: RangeEnd ;
2425use rustc_pattern_analysis:: rustc:: { DeconstructedPat , RustcPatCtxt } ;
2526use rustc_span:: { BytePos , Pos , Span , Symbol , sym} ;
2627use tracing:: { debug, instrument} ;
@@ -1892,7 +1893,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18921893 debug ! ( "expanding or-pattern: candidate={:#?}\n pats={:#?}" , candidate, pats) ;
18931894 candidate. or_span = Some ( match_pair. pattern_span ) ;
18941895 candidate. subcandidates = pats
1895- . into_vec ( )
18961896 . into_iter ( )
18971897 . map ( |flat_pat| Candidate :: from_flat_pat ( flat_pat, candidate. has_guard ) )
18981898 . collect ( ) ;
@@ -2976,6 +2976,34 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29762976 Ok ( actual_value) => * pattern_value == actual_value,
29772977 Err ( ( ) ) => bug ! ( "bool value with invalid bits" ) ,
29782978 } ,
2979+ Constructor :: F16Range ( l, h, end) => {
2980+ let actual = valtree. unwrap_leaf ( ) . to_f16 ( ) ;
2981+ match end {
2982+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
2983+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
2984+ }
2985+ }
2986+ Constructor :: F32Range ( l, h, end) => {
2987+ let actual = valtree. unwrap_leaf ( ) . to_f32 ( ) ;
2988+ match end {
2989+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
2990+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
2991+ }
2992+ }
2993+ Constructor :: F64Range ( l, h, end) => {
2994+ let actual = valtree. unwrap_leaf ( ) . to_f64 ( ) ;
2995+ match end {
2996+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
2997+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
2998+ }
2999+ }
3000+ Constructor :: F128Range ( l, h, end) => {
3001+ let actual = valtree. unwrap_leaf ( ) . to_f128 ( ) ;
3002+ match end {
3003+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
3004+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
3005+ }
3006+ }
29793007 Constructor :: Wildcard => true ,
29803008
29813009 // These we may eventually support:
@@ -2984,10 +3012,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29843012 | Constructor :: Slice ( _)
29853013 | Constructor :: UnionField
29863014 | Constructor :: Or
2987- | Constructor :: F16Range ( ..)
2988- | Constructor :: F32Range ( ..)
2989- | Constructor :: F64Range ( ..)
2990- | Constructor :: F128Range ( ..)
29913015 | Constructor :: Str ( _) => bug ! ( "unsupported pattern constructor {:?}" , pat. ctor( ) ) ,
29923016
29933017 // These should never occur here:
0 commit comments