@@ -24,7 +24,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
24
24
/// Identifies what test is needed to decide if `match_pair` is applicable.
25
25
///
26
26
/// It is a bug to call this with a simplifiable pattern.
27
- crate fn test < ' pat > ( & mut self , match_pair : & MatchPair < ' pat , ' tcx > ) -> Test < ' tcx > {
27
+ pub ( super ) fn test < ' pat > ( & mut self , match_pair : & MatchPair < ' pat , ' tcx > ) -> Test < ' tcx > {
28
28
match * match_pair. pattern . kind {
29
29
PatKind :: Variant { ref adt_def, substs : _, variant_index : _, subpatterns : _ } => Test {
30
30
span : match_pair. pattern . span ,
@@ -70,11 +70,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
70
70
}
71
71
}
72
72
73
- PatKind :: Or { .. } => self
74
- . hir
75
- . tcx ( )
76
- . sess
77
- . span_fatal ( match_pair. pattern . span , "or-patterns are not fully implemented yet" ) ,
73
+ PatKind :: Or { .. } => bug ! ( "or-patterns should have already been handled" ) ,
78
74
79
75
PatKind :: AscribeUserType { .. }
80
76
| PatKind :: Array { .. }
@@ -85,7 +81,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
85
81
}
86
82
}
87
83
88
- crate fn add_cases_to_switch < ' pat > (
84
+ pub ( super ) fn add_cases_to_switch < ' pat > (
89
85
& mut self ,
90
86
test_place : & Place < ' tcx > ,
91
87
candidate : & Candidate < ' pat , ' tcx > ,
@@ -129,7 +125,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
129
125
}
130
126
}
131
127
132
- crate fn add_variants_to_switch < ' pat > (
128
+ pub ( super ) fn add_variants_to_switch < ' pat > (
133
129
& mut self ,
134
130
test_place : & Place < ' tcx > ,
135
131
candidate : & Candidate < ' pat , ' tcx > ,
@@ -156,10 +152,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
156
152
}
157
153
}
158
154
159
- crate fn perform_test (
155
+ pub ( super ) fn perform_test (
160
156
& mut self ,
161
157
block : BasicBlock ,
162
- place : & Place < ' tcx > ,
158
+ place : Place < ' tcx > ,
163
159
test : & Test < ' tcx > ,
164
160
make_target_blocks : impl FnOnce ( & mut Self ) -> Vec < BasicBlock > ,
165
161
) {
@@ -209,7 +205,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
209
205
) ;
210
206
let discr_ty = adt_def. repr . discr_type ( ) . to_ty ( tcx) ;
211
207
let discr = self . temp ( discr_ty, test. span ) ;
212
- self . cfg . push_assign ( block, source_info, & discr, Rvalue :: Discriminant ( * place) ) ;
208
+ self . cfg . push_assign ( block, source_info, & discr, Rvalue :: Discriminant ( place) ) ;
213
209
assert_eq ! ( values. len( ) + 1 , targets. len( ) ) ;
214
210
self . cfg . terminate (
215
211
block,
@@ -233,20 +229,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
233
229
0 => ( second_bb, first_bb) ,
234
230
v => span_bug ! ( test. span, "expected boolean value but got {:?}" , v) ,
235
231
} ;
236
- TerminatorKind :: if_ (
237
- self . hir . tcx ( ) ,
238
- Operand :: Copy ( * place) ,
239
- true_bb,
240
- false_bb,
241
- )
232
+ TerminatorKind :: if_ ( self . hir . tcx ( ) , Operand :: Copy ( place) , true_bb, false_bb)
242
233
} else {
243
234
bug ! ( "`TestKind::SwitchInt` on `bool` should have two targets" )
244
235
}
245
236
} else {
246
237
// The switch may be inexhaustive so we have a catch all block
247
238
debug_assert_eq ! ( options. len( ) + 1 , target_blocks. len( ) ) ;
248
239
TerminatorKind :: SwitchInt {
249
- discr : Operand :: Copy ( * place) ,
240
+ discr : Operand :: Copy ( place) ,
250
241
switch_ty,
251
242
values : options. clone ( ) . into ( ) ,
252
243
targets : target_blocks,
@@ -271,7 +262,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
271
262
if let [ success, fail] = * make_target_blocks ( self ) {
272
263
assert_eq ! ( value. ty, ty) ;
273
264
let expect = self . literal_operand ( test. span , value) ;
274
- let val = Operand :: Copy ( * place) ;
265
+ let val = Operand :: Copy ( place) ;
275
266
self . compare ( block, success, fail, source_info, BinOp :: Eq , expect, val) ;
276
267
} else {
277
268
bug ! ( "`TestKind::Eq` should have two target blocks" ) ;
@@ -286,7 +277,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
286
277
// Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
287
278
let lo = self . literal_operand ( test. span , lo) ;
288
279
let hi = self . literal_operand ( test. span , hi) ;
289
- let val = Operand :: Copy ( * place) ;
280
+ let val = Operand :: Copy ( place) ;
290
281
291
282
if let [ success, fail] = * target_blocks {
292
283
self . compare (
@@ -315,7 +306,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
315
306
let actual = self . temp ( usize_ty, test. span ) ;
316
307
317
308
// actual = len(place)
318
- self . cfg . push_assign ( block, source_info, & actual, Rvalue :: Len ( * place) ) ;
309
+ self . cfg . push_assign ( block, source_info, & actual, Rvalue :: Len ( place) ) ;
319
310
320
311
// expected = <N>
321
312
let expected = self . push_usize ( block, source_info, len) ;
@@ -371,13 +362,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
371
362
make_target_blocks : impl FnOnce ( & mut Self ) -> Vec < BasicBlock > ,
372
363
source_info : SourceInfo ,
373
364
value : & ' tcx ty:: Const < ' tcx > ,
374
- place : & Place < ' tcx > ,
365
+ place : Place < ' tcx > ,
375
366
mut ty : Ty < ' tcx > ,
376
367
) {
377
368
use rustc:: middle:: lang_items:: EqTraitLangItem ;
378
369
379
370
let mut expect = self . literal_operand ( source_info. span , value) ;
380
- let mut val = Operand :: Copy ( * place) ;
371
+ let mut val = Operand :: Copy ( place) ;
381
372
382
373
// If we're using `b"..."` as a pattern, we need to insert an
383
374
// unsizing coercion, as the byte string has the type `&[u8; N]`.
@@ -502,7 +493,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
502
493
/// that it *doesn't* apply. For now, we return false, indicate that the
503
494
/// test does not apply to this candidate, but it might be we can get
504
495
/// tighter match code if we do something a bit different.
505
- crate fn sort_candidate < ' pat > (
496
+ pub ( super ) fn sort_candidate < ' pat > (
506
497
& mut self ,
507
498
test_place : & Place < ' tcx > ,
508
499
test : & Test < ' tcx > ,
@@ -755,8 +746,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
755
746
let downcast_place = tcx. mk_place_elem ( match_pair. place , elem) ; // `(x as Variant)`
756
747
let consequent_match_pairs = subpatterns. iter ( ) . map ( |subpattern| {
757
748
// e.g., `(x as Variant).0`
758
- let place =
759
- tcx. mk_place_field ( downcast_place. clone ( ) , subpattern. field , subpattern. pattern . ty ) ;
749
+ let place = tcx. mk_place_field ( downcast_place, subpattern. field , subpattern. pattern . ty ) ;
760
750
// e.g., `(x as Variant).0 @ P1`
761
751
MatchPair :: new ( place, & subpattern. pattern )
762
752
} ) ;
0 commit comments