@@ -1231,9 +1231,9 @@ impl<'tcx> IntRange<'tcx> {
1231
1231
( * self . range . start ( ) , * self . range . end ( ) )
1232
1232
}
1233
1233
1234
+ /// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching` feature
1235
+ /// is enabled.
1234
1236
fn treat_exhaustively ( & self , tcx : TyCtxt < ' tcx > ) -> bool {
1235
- // Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
1236
- // feature is enabled.
1237
1237
!self . ty . is_ptr_sized_integral ( ) || tcx. features ( ) . precise_pointer_size_matching
1238
1238
}
1239
1239
@@ -1416,7 +1416,7 @@ impl<'tcx> IntRange<'tcx> {
1416
1416
}
1417
1417
}
1418
1418
1419
- // Ignore spans when comparing, they don't carry semantic information as they are only for lints.
1419
+ /// Ignore spans when comparing, they don't carry semantic information as they are only for lints.
1420
1420
impl < ' tcx > std:: cmp:: PartialEq for IntRange < ' tcx > {
1421
1421
fn eq ( & self , other : & Self ) -> bool {
1422
1422
self . range == other. range && self . ty == other. ty
@@ -2079,9 +2079,9 @@ fn constructor_covered_by_range<'tcx>(
2079
2079
param_env : ty:: ParamEnv < ' tcx > ,
2080
2080
ctor : & Constructor < ' tcx > ,
2081
2081
pat : & Pat < ' tcx > ,
2082
- ) -> bool {
2082
+ ) -> Option < ( ) > {
2083
2083
if let Single = ctor {
2084
- return true ;
2084
+ return Some ( ( ) ) ;
2085
2085
}
2086
2086
2087
2087
let ( pat_from, pat_to, pat_end, ty) = match * pat. kind {
@@ -2096,16 +2096,11 @@ fn constructor_covered_by_range<'tcx>(
2096
2096
} ;
2097
2097
trace ! ( "constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}" , ctor, pat_from, pat_to, ty) ;
2098
2098
2099
- let to = match compare_const_vals ( tcx, ctor_to, pat_to, param_env, ty) {
2100
- Some ( to) => to,
2101
- None => return false ,
2102
- } ;
2103
- let from = match compare_const_vals ( tcx, ctor_from, pat_from, param_env, ty) {
2104
- Some ( from) => from,
2105
- None => return false ,
2106
- } ;
2107
- ( from == Ordering :: Greater || from == Ordering :: Equal )
2108
- && ( to == Ordering :: Less || ( pat_end == ctor_end && to == Ordering :: Equal ) )
2099
+ let to = compare_const_vals ( tcx, ctor_to, pat_to, param_env, ty) ?;
2100
+ let from = compare_const_vals ( tcx, ctor_from, pat_from, param_env, ty) ?;
2101
+ let intersects = ( from == Ordering :: Greater || from == Ordering :: Equal )
2102
+ && ( to == Ordering :: Less || ( pat_end == ctor_end && to == Ordering :: Equal ) ) ;
2103
+ if intersects { Some ( ( ) ) } else { None }
2109
2104
}
2110
2105
2111
2106
fn patterns_for_variant < ' p , ' a : ' p , ' tcx > (
@@ -2251,11 +2246,8 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
2251
2246
// by `IntRange`. For these cases, the constructor may not be a
2252
2247
// range so intersection actually devolves into being covered
2253
2248
// by the pattern.
2254
- if constructor_covered_by_range ( cx. tcx , cx. param_env , constructor, pat) {
2255
- Some ( PatStack :: default ( ) )
2256
- } else {
2257
- None
2258
- }
2249
+ constructor_covered_by_range ( cx. tcx , cx. param_env , constructor, pat)
2250
+ . map ( |( ) | PatStack :: default ( ) )
2259
2251
}
2260
2252
}
2261
2253
0 commit comments