@@ -1180,9 +1180,9 @@ impl<'tcx> IntRange<'tcx> {
1180
1180
( * self . range . start ( ) , * self . range . end ( ) )
1181
1181
}
1182
1182
1183
+ /// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching` feature
1184
+ /// is enabled.
1183
1185
fn treat_exhaustively ( & self , tcx : TyCtxt < ' tcx > ) -> bool {
1184
- // Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
1185
- // feature is enabled.
1186
1186
!self . ty . is_ptr_sized_integral ( ) || tcx. features ( ) . precise_pointer_size_matching
1187
1187
}
1188
1188
@@ -1363,7 +1363,7 @@ impl<'tcx> IntRange<'tcx> {
1363
1363
}
1364
1364
}
1365
1365
1366
- // Ignore spans when comparing, they don't carry semantic information as they are only for lints.
1366
+ /// Ignore spans when comparing, they don't carry semantic information as they are only for lints.
1367
1367
impl < ' tcx > std:: cmp:: PartialEq for IntRange < ' tcx > {
1368
1368
fn eq ( & self , other : & Self ) -> bool {
1369
1369
self . range == other. range && self . ty == other. ty
@@ -2056,9 +2056,9 @@ fn constructor_covered_by_range<'tcx>(
2056
2056
param_env : ty:: ParamEnv < ' tcx > ,
2057
2057
ctor : & Constructor < ' tcx > ,
2058
2058
pat : & Pat < ' tcx > ,
2059
- ) -> bool {
2059
+ ) -> Option < ( ) > {
2060
2060
if let Single = ctor {
2061
- return true ;
2061
+ return Some ( ( ) ) ;
2062
2062
}
2063
2063
2064
2064
let ( pat_from, pat_to, pat_end, ty) = match * pat. kind {
@@ -2073,16 +2073,11 @@ fn constructor_covered_by_range<'tcx>(
2073
2073
} ;
2074
2074
trace ! ( "constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}" , ctor, pat_from, pat_to, ty) ;
2075
2075
2076
- let to = match compare_const_vals ( tcx, ctor_to, pat_to, param_env, ty) {
2077
- Some ( to) => to,
2078
- None => return false ,
2079
- } ;
2080
- let from = match compare_const_vals ( tcx, ctor_from, pat_from, param_env, ty) {
2081
- Some ( from) => from,
2082
- None => return false ,
2083
- } ;
2084
- ( from == Ordering :: Greater || from == Ordering :: Equal )
2085
- && ( to == Ordering :: Less || ( pat_end == ctor_end && to == Ordering :: Equal ) )
2076
+ let to = compare_const_vals ( tcx, ctor_to, pat_to, param_env, ty) ?;
2077
+ let from = compare_const_vals ( tcx, ctor_from, pat_from, param_env, ty) ?;
2078
+ let intersects = ( from == Ordering :: Greater || from == Ordering :: Equal )
2079
+ && ( to == Ordering :: Less || ( pat_end == ctor_end && to == Ordering :: Equal ) ) ;
2080
+ if intersects { Some ( ( ) ) } else { None }
2086
2081
}
2087
2082
2088
2083
fn patterns_for_variant < ' p , ' a : ' p , ' tcx > (
@@ -2221,11 +2216,8 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
2221
2216
// by `IntRange`. For these cases, the constructor may not be a
2222
2217
// range so intersection actually devolves into being covered
2223
2218
// by the pattern.
2224
- if constructor_covered_by_range ( cx. tcx , cx. param_env , constructor, pat) {
2225
- Some ( PatStack :: default ( ) )
2226
- } else {
2227
- None
2228
- }
2219
+ constructor_covered_by_range ( cx. tcx , cx. param_env , constructor, pat)
2220
+ . map ( |( ) | PatStack :: default ( ) )
2229
2221
}
2230
2222
}
2231
2223
0 commit comments