@@ -58,12 +58,6 @@ impl<'tcx> IntRange<'tcx> {
58
58
( * self . range . start ( ) , * self . range . end ( ) )
59
59
}
60
60
61
- /// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching` feature
62
- /// is enabled.
63
- fn treat_exhaustively ( & self , tcx : TyCtxt < ' tcx > ) -> bool {
64
- !self . ty . is_ptr_sized_integral ( ) || tcx. features ( ) . precise_pointer_size_matching
65
- }
66
-
67
61
#[ inline]
68
62
fn integral_size_and_signed_bias ( tcx : TyCtxt < ' tcx > , ty : Ty < ' _ > ) -> Option < ( Size , u128 ) > {
69
63
match * ty. kind ( ) {
@@ -147,20 +141,15 @@ impl<'tcx> IntRange<'tcx> {
147
141
other. range . start ( ) <= self . range . start ( ) && self . range . end ( ) <= other. range . end ( )
148
142
}
149
143
150
- fn intersection ( & self , tcx : TyCtxt < ' tcx > , other : & Self ) -> Option < Self > {
144
+ fn intersection ( & self , other : & Self ) -> Option < Self > {
151
145
let ty = self . ty ;
152
146
let ( lo, hi) = self . boundaries ( ) ;
153
147
let ( other_lo, other_hi) = other. boundaries ( ) ;
154
- if self . treat_exhaustively ( tcx) {
155
- if lo <= other_hi && other_lo <= hi {
156
- let span = other. span ;
157
- Some ( IntRange { range : max ( lo, other_lo) ..=min ( hi, other_hi) , ty, span } )
158
- } else {
159
- None
160
- }
148
+ if lo <= other_hi && other_lo <= hi {
149
+ let span = other. span ;
150
+ Some ( IntRange { range : max ( lo, other_lo) ..=min ( hi, other_hi) , ty, span } )
161
151
} else {
162
- // If the range should not be treated exhaustively, fallback to checking for inclusion.
163
- if self . is_subrange ( other) { Some ( self . clone ( ) ) } else { None }
152
+ None
164
153
}
165
154
}
166
155
@@ -271,7 +260,7 @@ impl<'tcx> IntRange<'tcx> {
271
260
. head_ctors ( pcx. cx )
272
261
. filter_map ( |ctor| ctor. as_int_range ( ) )
273
262
. filter_map ( |range| {
274
- let intersection = self . intersection ( pcx . cx . tcx , & range) ;
263
+ let intersection = self . intersection ( & range) ;
275
264
let should_lint = self . suspicious_intersection ( & range) ;
276
265
if let ( Some ( range) , 1 , true ) = ( & intersection, row_len, should_lint) {
277
266
// FIXME: for now, only check for overlapping ranges on simple range
@@ -346,8 +335,8 @@ impl<'tcx> IntRange<'tcx> {
346
335
}
347
336
348
337
/// See `Constructor::is_covered_by`
349
- fn is_covered_by < ' p > ( & self , pcx : PatCtxt < ' _ , ' p , ' tcx > , other : & Self ) -> bool {
350
- if self . intersection ( pcx . cx . tcx , other) . is_some ( ) {
338
+ fn is_covered_by ( & self , other : & Self ) -> bool {
339
+ if self . intersection ( other) . is_some ( ) {
351
340
// Constructor splitting should ensure that all intersections we encounter are actually
352
341
// inclusions.
353
342
assert ! ( self . is_subrange( other) ) ;
@@ -694,11 +683,7 @@ impl<'tcx> Constructor<'tcx> {
694
683
Wildcard => Constructor :: split_wildcard ( pcx) ,
695
684
// Fast-track if the range is trivial. In particular, we don't do the overlapping
696
685
// ranges check.
697
- IntRange ( ctor_range)
698
- if ctor_range. treat_exhaustively ( pcx. cx . tcx ) && !ctor_range. is_singleton ( ) =>
699
- {
700
- ctor_range. split ( pcx, hir_id)
701
- }
686
+ IntRange ( ctor_range) if !ctor_range. is_singleton ( ) => ctor_range. split ( pcx, hir_id) ,
702
687
Slice ( slice @ Slice { kind : VarLen ( ..) , .. } ) => slice. split ( pcx) ,
703
688
// Any other constructor can be used unchanged.
704
689
_ => smallvec ! [ self . clone( ) ] ,
@@ -740,9 +725,7 @@ impl<'tcx> Constructor<'tcx> {
740
725
( Single , Single ) => true ,
741
726
( Variant ( self_id) , Variant ( other_id) ) => self_id == other_id,
742
727
743
- ( IntRange ( self_range) , IntRange ( other_range) ) => {
744
- self_range. is_covered_by ( pcx, other_range)
745
- }
728
+ ( IntRange ( self_range) , IntRange ( other_range) ) => self_range. is_covered_by ( other_range) ,
746
729
(
747
730
FloatRange ( self_from, self_to, self_end) ,
748
731
FloatRange ( other_from, other_to, other_end) ,
@@ -803,15 +786,15 @@ impl<'tcx> Constructor<'tcx> {
803
786
IntRange ( range) => used_ctors
804
787
. iter ( )
805
788
. filter_map ( |c| c. as_int_range ( ) )
806
- . any ( |other| range. is_covered_by ( pcx , other) ) ,
789
+ . any ( |other| range. is_covered_by ( other) ) ,
807
790
Slice ( slice) => used_ctors
808
791
. iter ( )
809
792
. filter_map ( |c| c. as_slice ( ) )
810
793
. any ( |other| slice. is_covered_by ( other) ) ,
811
794
// This constructor is never covered by anything else
812
795
NonExhaustive => false ,
813
796
Str ( ..) | FloatRange ( ..) | Opaque | Wildcard => {
814
- bug ! ( "found unexpected ctor in all_ctors: {:?}" , self )
797
+ span_bug ! ( pcx . span , "found unexpected ctor in all_ctors: {:?}" , self )
815
798
}
816
799
}
817
800
}
0 commit comments