@@ -21,6 +21,7 @@ use rustc_middle::ty::{
21
21
self , CanonicalUserTypeAnnotation , Ty , TypeVisitableExt , ValTree , ValTreeKind ,
22
22
} ;
23
23
use rustc_middle:: { bug, span_bug} ;
24
+ use rustc_pattern_analysis:: constructor:: RangeEnd ;
24
25
use rustc_pattern_analysis:: rustc:: { DeconstructedPat , RustcPatCtxt } ;
25
26
use rustc_span:: { BytePos , Pos , Span , Symbol , sym} ;
26
27
use tracing:: { debug, instrument} ;
@@ -1892,7 +1893,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1892
1893
debug ! ( "expanding or-pattern: candidate={:#?}\n pats={:#?}" , candidate, pats) ;
1893
1894
candidate. or_span = Some ( match_pair. pattern_span ) ;
1894
1895
candidate. subcandidates = pats
1895
- . into_vec ( )
1896
1896
. into_iter ( )
1897
1897
. map ( |flat_pat| Candidate :: from_flat_pat ( flat_pat, candidate. has_guard ) )
1898
1898
. collect ( ) ;
@@ -2976,6 +2976,34 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2976
2976
Ok ( actual_value) => * pattern_value == actual_value,
2977
2977
Err ( ( ) ) => bug ! ( "bool value with invalid bits" ) ,
2978
2978
} ,
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
+ }
2979
3007
Constructor :: Wildcard => true ,
2980
3008
2981
3009
// These we may eventually support:
@@ -2984,10 +3012,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2984
3012
| Constructor :: Slice ( _)
2985
3013
| Constructor :: UnionField
2986
3014
| Constructor :: Or
2987
- | Constructor :: F16Range ( ..)
2988
- | Constructor :: F32Range ( ..)
2989
- | Constructor :: F64Range ( ..)
2990
- | Constructor :: F128Range ( ..)
2991
3015
| Constructor :: Str ( _) => bug ! ( "unsupported pattern constructor {:?}" , pat. ctor( ) ) ,
2992
3016
2993
3017
// These should never occur here:
0 commit comments