@@ -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} ;
@@ -1893,7 +1894,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18931894 debug ! ( "expanding or-pattern: candidate={:#?}\n pats={:#?}" , candidate, pats) ;
18941895 candidate. or_span = Some ( match_pair. pattern_span ) ;
18951896 candidate. subcandidates = pats
1896- . into_vec ( )
18971897 . into_iter ( )
18981898 . map ( |flat_pat| Candidate :: from_flat_pat ( flat_pat, candidate. has_guard ) )
18991899 . collect ( ) ;
@@ -2977,6 +2977,34 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29772977 Ok ( actual_value) => * pattern_value == actual_value,
29782978 Err ( ( ) ) => bug ! ( "bool value with invalid bits" ) ,
29792979 } ,
2980+ Constructor :: F16Range ( l, h, end) => {
2981+ let actual = valtree. unwrap_leaf ( ) . to_f16 ( ) ;
2982+ match end {
2983+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
2984+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
2985+ }
2986+ }
2987+ Constructor :: F32Range ( l, h, end) => {
2988+ let actual = valtree. unwrap_leaf ( ) . to_f32 ( ) ;
2989+ match end {
2990+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
2991+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
2992+ }
2993+ }
2994+ Constructor :: F64Range ( l, h, end) => {
2995+ let actual = valtree. unwrap_leaf ( ) . to_f64 ( ) ;
2996+ match end {
2997+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
2998+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
2999+ }
3000+ }
3001+ Constructor :: F128Range ( l, h, end) => {
3002+ let actual = valtree. unwrap_leaf ( ) . to_f128 ( ) ;
3003+ match end {
3004+ RangeEnd :: Included => ( * l..=* h) . contains ( & actual) ,
3005+ RangeEnd :: Excluded => ( * l..* h) . contains ( & actual) ,
3006+ }
3007+ }
29803008 Constructor :: Wildcard => true ,
29813009
29823010 // These we may eventually support:
@@ -2985,10 +3013,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29853013 | Constructor :: Slice ( _)
29863014 | Constructor :: UnionField
29873015 | Constructor :: Or
2988- | Constructor :: F16Range ( ..)
2989- | Constructor :: F32Range ( ..)
2990- | Constructor :: F64Range ( ..)
2991- | Constructor :: F128Range ( ..)
29923016 | Constructor :: Str ( _) => bug ! ( "unsupported pattern constructor {:?}" , pat. ctor( ) ) ,
29933017
29943018 // These should never occur here:
0 commit comments