@@ -20,42 +20,8 @@ use std::mem;
20
20
21
21
impl < ' a , ' tcx > Builder < ' a , ' tcx > {
22
22
/// Simplify a candidate so that all match pairs require a test.
23
- ///
24
- /// This method will also split a candidate, in which the only
25
- /// match-pair is an or-pattern, into multiple candidates.
26
- /// This is so that
27
- ///
28
- /// match x {
29
- /// 0 | 1 => { ... },
30
- /// 2 | 3 => { ... },
31
- /// }
32
- ///
33
- /// only generates a single switch. If this happens this method returns
34
- /// `true`.
35
23
#[ instrument( skip( self ) , level = "debug" ) ]
36
24
pub ( super ) fn simplify_candidate < ' pat > (
37
- & mut self ,
38
- bindings : & mut Vec < Binding < ' tcx > > ,
39
- ascriptions : & mut Vec < Ascription < ' tcx > > ,
40
- match_pairs : & mut Vec < MatchPair < ' pat , ' tcx > > ,
41
- subcandidates : & mut Vec < Candidate < ' pat , ' tcx > > ,
42
- has_guard : bool ,
43
- ) -> bool {
44
- self . simplify_candidate_inner ( bindings, ascriptions, match_pairs) ;
45
-
46
- if let [ MatchPair { pattern : Pat { kind : PatKind :: Or { pats } , .. } , place, .. } ] =
47
- & * * match_pairs
48
- {
49
- * subcandidates = self . create_or_subcandidates ( place, pats, has_guard) ;
50
- match_pairs. pop ( ) ;
51
- return true ;
52
- }
53
-
54
- false
55
- }
56
-
57
- #[ instrument( skip( self ) , level = "debug" ) ]
58
- pub ( super ) fn simplify_candidate_inner < ' pat > (
59
25
& mut self ,
60
26
candidate_bindings : & mut Vec < Binding < ' tcx > > ,
61
27
candidate_ascriptions : & mut Vec < Ascription < ' tcx > > ,
@@ -144,7 +110,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
144
110
/// Given `candidate` that has a single or-pattern for its match-pairs,
145
111
/// creates a fresh candidate for each of its input subpatterns passed via
146
112
/// `pats`.
147
- fn create_or_subcandidates < ' pat > (
113
+ pub ( super ) fn create_or_subcandidates < ' pat > (
148
114
& mut self ,
149
115
place : & PlaceBuilder < ' tcx > ,
150
116
pats : & ' pat [ Box < Pat < ' tcx > > ] ,
@@ -157,9 +123,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
157
123
& mut candidate. bindings ,
158
124
& mut candidate. ascriptions ,
159
125
& mut candidate. match_pairs ,
160
- & mut candidate. subcandidates ,
161
- candidate. has_guard ,
162
126
) ;
127
+
128
+ if let [ MatchPair { pattern : Pat { kind : PatKind :: Or { pats } , .. } , place, .. } ] =
129
+ & * candidate. match_pairs
130
+ {
131
+ candidate. subcandidates =
132
+ self . create_or_subcandidates ( place, pats, candidate. has_guard ) ;
133
+ candidate. match_pairs . pop ( ) ;
134
+ }
163
135
candidate
164
136
} )
165
137
. collect ( )
0 commit comments