@@ -58,10 +58,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
58
58
kind : TestKind :: Eq { value, ty : match_pair. pattern . ty } ,
59
59
} ,
60
60
61
- PatKind :: Range ( range) => {
61
+ PatKind :: Range ( ref range) => {
62
62
assert_eq ! ( range. lo. ty( ) , match_pair. pattern. ty) ;
63
63
assert_eq ! ( range. hi. ty( ) , match_pair. pattern. ty) ;
64
- Test { span : match_pair. pattern . span , kind : TestKind :: Range ( range) }
64
+ Test { span : match_pair. pattern . span , kind : TestKind :: Range ( range. clone ( ) ) }
65
65
}
66
66
67
67
PatKind :: Slice { ref prefix, ref slice, ref suffix } => {
@@ -102,9 +102,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
102
102
PatKind :: Variant { .. } => {
103
103
panic ! ( "you should have called add_variants_to_switch instead!" ) ;
104
104
}
105
- PatKind :: Range ( range) => {
105
+ PatKind :: Range ( ref range) => {
106
106
// Check that none of the switch values are in the range.
107
- self . values_not_contained_in_range ( range, options) . unwrap_or ( false )
107
+ self . values_not_contained_in_range ( & * range, options) . unwrap_or ( false )
108
108
}
109
109
PatKind :: Slice { .. }
110
110
| PatKind :: Array { .. }
@@ -272,7 +272,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
272
272
}
273
273
}
274
274
275
- TestKind :: Range ( PatRange { lo, hi, ref end } ) => {
275
+ TestKind :: Range ( box PatRange { lo, hi, ref end } ) => {
276
276
let lower_bound_success = self . cfg . start_new_block ( ) ;
277
277
let target_blocks = make_target_blocks ( self ) ;
278
278
@@ -540,9 +540,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
540
540
Some ( index)
541
541
}
542
542
543
- ( & TestKind :: SwitchInt { switch_ty : _, ref options } , & PatKind :: Range ( range) ) => {
543
+ ( & TestKind :: SwitchInt { switch_ty : _, ref options } , & PatKind :: Range ( ref range) ) => {
544
544
let not_contained =
545
- self . values_not_contained_in_range ( range, options) . unwrap_or ( false ) ;
545
+ self . values_not_contained_in_range ( & * range, options) . unwrap_or ( false ) ;
546
546
547
547
if not_contained {
548
548
// No switch values are contained in the pattern range,
@@ -631,7 +631,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
631
631
}
632
632
}
633
633
634
- ( & TestKind :: Range ( test) , & PatKind :: Range ( pat) ) => {
634
+ ( & TestKind :: Range ( ref test) , & PatKind :: Range ( ref pat) ) => {
635
635
use std:: cmp:: Ordering :: * ;
636
636
637
637
if test == pat {
@@ -658,8 +658,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
658
658
no_overlap
659
659
}
660
660
661
- ( & TestKind :: Range ( range) , & PatKind :: Constant { value } ) => {
662
- if let Some ( false ) = self . const_range_contains ( range, value) {
661
+ ( & TestKind :: Range ( ref range) , & PatKind :: Constant { value } ) => {
662
+ if let Some ( false ) = self . const_range_contains ( & * range, value) {
663
663
// `value` is not contained in the testing range,
664
664
// so `value` can be matched only if this test fails.
665
665
Some ( 1 )
@@ -754,7 +754,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
754
754
755
755
fn const_range_contains (
756
756
& self ,
757
- range : PatRange < ' tcx > ,
757
+ range : & PatRange < ' tcx > ,
758
758
value : ConstantKind < ' tcx > ,
759
759
) -> Option < bool > {
760
760
use std:: cmp:: Ordering :: * ;
@@ -772,7 +772,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
772
772
773
773
fn values_not_contained_in_range (
774
774
& self ,
775
- range : PatRange < ' tcx > ,
775
+ range : & PatRange < ' tcx > ,
776
776
options : & FxIndexMap < ConstantKind < ' tcx > , u128 > ,
777
777
) -> Option < bool > {
778
778
for & val in options. keys ( ) {
0 commit comments