@@ -1231,9 +1231,9 @@ impl<'tcx> IntRange<'tcx> {
12311231 ( * self . range . start ( ) , * self . range . end ( ) )
12321232 }
12331233
1234+ /// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching` feature
1235+ /// is enabled.
12341236 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.
12371237 !self . ty . is_ptr_sized_integral ( ) || tcx. features ( ) . precise_pointer_size_matching
12381238 }
12391239
@@ -1416,7 +1416,7 @@ impl<'tcx> IntRange<'tcx> {
14161416 }
14171417}
14181418
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.
14201420impl < ' tcx > std:: cmp:: PartialEq for IntRange < ' tcx > {
14211421 fn eq ( & self , other : & Self ) -> bool {
14221422 self . range == other. range && self . ty == other. ty
@@ -2079,9 +2079,9 @@ fn constructor_covered_by_range<'tcx>(
20792079 param_env : ty:: ParamEnv < ' tcx > ,
20802080 ctor : & Constructor < ' tcx > ,
20812081 pat : & Pat < ' tcx > ,
2082- ) -> bool {
2082+ ) -> Option < ( ) > {
20832083 if let Single = ctor {
2084- return true ;
2084+ return Some ( ( ) ) ;
20852085 }
20862086
20872087 let ( pat_from, pat_to, pat_end, ty) = match * pat. kind {
@@ -2096,16 +2096,11 @@ fn constructor_covered_by_range<'tcx>(
20962096 } ;
20972097 trace ! ( "constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}" , ctor, pat_from, pat_to, ty) ;
20982098
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 }
21092104}
21102105
21112106fn patterns_for_variant < ' p , ' a : ' p , ' tcx > (
@@ -2251,11 +2246,8 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
22512246 // by `IntRange`. For these cases, the constructor may not be a
22522247 // range so intersection actually devolves into being covered
22532248 // 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 ( ) )
22592251 }
22602252 }
22612253
0 commit comments