@@ -26,7 +26,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
26
26
/// It is a bug to call this with a simplifiable pattern.
27
27
pub fn test < ' pat > ( & mut self , match_pair : & MatchPair < ' pat , ' tcx > ) -> Test < ' tcx > {
28
28
match * match_pair. pattern . kind {
29
- PatternKind :: Variant { ref adt_def, substs : _, variant_index : _, subpatterns : _ } => {
29
+ PatKind :: Variant { ref adt_def, substs : _, variant_index : _, subpatterns : _ } => {
30
30
Test {
31
31
span : match_pair. pattern . span ,
32
32
kind : TestKind :: Switch {
@@ -36,7 +36,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
36
36
}
37
37
}
38
38
39
- PatternKind :: Constant { .. } if is_switch_ty ( match_pair. pattern . ty ) => {
39
+ PatKind :: Constant { .. } if is_switch_ty ( match_pair. pattern . ty ) => {
40
40
// For integers, we use a `SwitchInt` match, which allows
41
41
// us to handle more cases.
42
42
Test {
@@ -52,7 +52,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
52
52
}
53
53
}
54
54
55
- PatternKind :: Constant { value } => {
55
+ PatKind :: Constant { value } => {
56
56
Test {
57
57
span : match_pair. pattern . span ,
58
58
kind : TestKind :: Eq {
@@ -62,7 +62,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
62
62
}
63
63
}
64
64
65
- PatternKind :: Range ( range) => {
65
+ PatKind :: Range ( range) => {
66
66
assert_eq ! ( range. lo. ty, match_pair. pattern. ty) ;
67
67
assert_eq ! ( range. hi. ty, match_pair. pattern. ty) ;
68
68
Test {
@@ -71,7 +71,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
71
71
}
72
72
}
73
73
74
- PatternKind :: Slice { ref prefix, ref slice, ref suffix } => {
74
+ PatKind :: Slice { ref prefix, ref slice, ref suffix } => {
75
75
let len = prefix. len ( ) + suffix. len ( ) ;
76
76
let op = if slice. is_some ( ) {
77
77
BinOp :: Ge
@@ -84,13 +84,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
84
84
}
85
85
}
86
86
87
- PatternKind :: AscribeUserType { .. } |
88
- PatternKind :: Array { .. } |
89
- PatternKind :: Wild |
90
- PatternKind :: Or { .. } |
91
- PatternKind :: Binding { .. } |
92
- PatternKind :: Leaf { .. } |
93
- PatternKind :: Deref { .. } => {
87
+ PatKind :: AscribeUserType { .. } |
88
+ PatKind :: Array { .. } |
89
+ PatKind :: Wild |
90
+ PatKind :: Or { .. } |
91
+ PatKind :: Binding { .. } |
92
+ PatKind :: Leaf { .. } |
93
+ PatKind :: Deref { .. } => {
94
94
self . error_simplifyable ( match_pair)
95
95
}
96
96
}
@@ -110,7 +110,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
110
110
} ;
111
111
112
112
match * match_pair. pattern . kind {
113
- PatternKind :: Constant { value } => {
113
+ PatKind :: Constant { value } => {
114
114
indices. entry ( value)
115
115
. or_insert_with ( || {
116
116
options. push ( value. eval_bits (
@@ -120,22 +120,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
120
120
} ) ;
121
121
true
122
122
}
123
- PatternKind :: Variant { .. } => {
123
+ PatKind :: Variant { .. } => {
124
124
panic ! ( "you should have called add_variants_to_switch instead!" ) ;
125
125
}
126
- PatternKind :: Range ( range) => {
126
+ PatKind :: Range ( range) => {
127
127
// Check that none of the switch values are in the range.
128
128
self . values_not_contained_in_range ( range, indices)
129
129
. unwrap_or ( false )
130
130
}
131
- PatternKind :: Slice { .. } |
132
- PatternKind :: Array { .. } |
133
- PatternKind :: Wild |
134
- PatternKind :: Or { .. } |
135
- PatternKind :: Binding { .. } |
136
- PatternKind :: AscribeUserType { .. } |
137
- PatternKind :: Leaf { .. } |
138
- PatternKind :: Deref { .. } => {
131
+ PatKind :: Slice { .. } |
132
+ PatKind :: Array { .. } |
133
+ PatKind :: Wild |
134
+ PatKind :: Or { .. } |
135
+ PatKind :: Binding { .. } |
136
+ PatKind :: AscribeUserType { .. } |
137
+ PatKind :: Leaf { .. } |
138
+ PatKind :: Deref { .. } => {
139
139
// don't know how to add these patterns to a switch
140
140
false
141
141
}
@@ -154,7 +154,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
154
154
} ;
155
155
156
156
match * match_pair. pattern . kind {
157
- PatternKind :: Variant { adt_def : _ , variant_index, .. } => {
157
+ PatKind :: Variant { adt_def : _ , variant_index, .. } => {
158
158
// We have a pattern testing for variant `variant_index`
159
159
// set the corresponding index to true
160
160
variants. insert ( variant_index) ;
@@ -533,7 +533,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
533
533
// If we are performing a variant switch, then this
534
534
// informs variant patterns, but nothing else.
535
535
( & TestKind :: Switch { adt_def : tested_adt_def, .. } ,
536
- & PatternKind :: Variant { adt_def, variant_index, ref subpatterns, .. } ) => {
536
+ & PatKind :: Variant { adt_def, variant_index, ref subpatterns, .. } ) => {
537
537
assert_eq ! ( adt_def, tested_adt_def) ;
538
538
self . candidate_after_variant_switch ( match_pair_index,
539
539
adt_def,
@@ -548,18 +548,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
548
548
// If we are performing a switch over integers, then this informs integer
549
549
// equality, but nothing else.
550
550
//
551
- // FIXME(#29623) we could use PatternKind ::Range to rule
551
+ // FIXME(#29623) we could use PatKind ::Range to rule
552
552
// things out here, in some cases.
553
553
( & TestKind :: SwitchInt { switch_ty : _, options : _, ref indices } ,
554
- & PatternKind :: Constant { ref value } )
554
+ & PatKind :: Constant { ref value } )
555
555
if is_switch_ty ( match_pair. pattern . ty ) => {
556
556
let index = indices[ value] ;
557
557
self . candidate_without_match_pair ( match_pair_index, candidate) ;
558
558
Some ( index)
559
559
}
560
560
561
561
( & TestKind :: SwitchInt { switch_ty : _, ref options, ref indices } ,
562
- & PatternKind :: Range ( range) ) => {
562
+ & PatKind :: Range ( range) ) => {
563
563
let not_contained = self
564
564
. values_not_contained_in_range ( range, indices)
565
565
. unwrap_or ( false ) ;
@@ -577,7 +577,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
577
577
( & TestKind :: SwitchInt { .. } , _) => None ,
578
578
579
579
( & TestKind :: Len { len : test_len, op : BinOp :: Eq } ,
580
- & PatternKind :: Slice { ref prefix, ref slice, ref suffix } ) => {
580
+ & PatKind :: Slice { ref prefix, ref slice, ref suffix } ) => {
581
581
let pat_len = ( prefix. len ( ) + suffix. len ( ) ) as u64 ;
582
582
match ( test_len. cmp ( & pat_len) , slice) {
583
583
( Ordering :: Equal , & None ) => {
@@ -610,7 +610,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
610
610
}
611
611
612
612
( & TestKind :: Len { len : test_len, op : BinOp :: Ge } ,
613
- & PatternKind :: Slice { ref prefix, ref slice, ref suffix } ) => {
613
+ & PatKind :: Slice { ref prefix, ref slice, ref suffix } ) => {
614
614
// the test is `$actual_len >= test_len`
615
615
let pat_len = ( prefix. len ( ) + suffix. len ( ) ) as u64 ;
616
616
match ( test_len. cmp ( & pat_len) , slice) {
@@ -644,7 +644,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
644
644
}
645
645
646
646
( & TestKind :: Range ( test) ,
647
- & PatternKind :: Range ( pat) ) => {
647
+ & PatKind :: Range ( pat) ) => {
648
648
if test == pat {
649
649
self . candidate_without_match_pair (
650
650
match_pair_index,
@@ -683,7 +683,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
683
683
}
684
684
}
685
685
686
- ( & TestKind :: Range ( range) , & PatternKind :: Constant { value } ) => {
686
+ ( & TestKind :: Range ( range) , & PatKind :: Constant { value } ) => {
687
687
if self . const_range_contains ( range, value) == Some ( false ) {
688
688
// `value` is not contained in the testing range,
689
689
// so `value` can be matched only if this test fails.
0 commit comments