@@ -24,7 +24,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2424 /// Identifies what test is needed to decide if `match_pair` is applicable.
2525 ///
2626 /// 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 > {
2828 match * match_pair. pattern . kind {
2929 PatKind :: Variant { ref adt_def, substs : _, variant_index : _, subpatterns : _ } => Test {
3030 span : match_pair. pattern . span ,
@@ -70,11 +70,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7070 }
7171 }
7272
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" ) ,
7874
7975 PatKind :: AscribeUserType { .. }
8076 | PatKind :: Array { .. }
@@ -85,7 +81,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8581 }
8682 }
8783
88- crate fn add_cases_to_switch < ' pat > (
84+ pub ( super ) fn add_cases_to_switch < ' pat > (
8985 & mut self ,
9086 test_place : & Place < ' tcx > ,
9187 candidate : & Candidate < ' pat , ' tcx > ,
@@ -129,7 +125,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
129125 }
130126 }
131127
132- crate fn add_variants_to_switch < ' pat > (
128+ pub ( super ) fn add_variants_to_switch < ' pat > (
133129 & mut self ,
134130 test_place : & Place < ' tcx > ,
135131 candidate : & Candidate < ' pat , ' tcx > ,
@@ -156,10 +152,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
156152 }
157153 }
158154
159- crate fn perform_test (
155+ pub ( super ) fn perform_test (
160156 & mut self ,
161157 block : BasicBlock ,
162- place : & Place < ' tcx > ,
158+ place : Place < ' tcx > ,
163159 test : & Test < ' tcx > ,
164160 make_target_blocks : impl FnOnce ( & mut Self ) -> Vec < BasicBlock > ,
165161 ) {
@@ -209,7 +205,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
209205 ) ;
210206 let discr_ty = adt_def. repr . discr_type ( ) . to_ty ( tcx) ;
211207 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) ) ;
213209 assert_eq ! ( values. len( ) + 1 , targets. len( ) ) ;
214210 self . cfg . terminate (
215211 block,
@@ -233,20 +229,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
233229 0 => ( second_bb, first_bb) ,
234230 v => span_bug ! ( test. span, "expected boolean value but got {:?}" , v) ,
235231 } ;
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)
242233 } else {
243234 bug ! ( "`TestKind::SwitchInt` on `bool` should have two targets" )
244235 }
245236 } else {
246237 // The switch may be inexhaustive so we have a catch all block
247238 debug_assert_eq ! ( options. len( ) + 1 , target_blocks. len( ) ) ;
248239 TerminatorKind :: SwitchInt {
249- discr : Operand :: Copy ( * place) ,
240+ discr : Operand :: Copy ( place) ,
250241 switch_ty,
251242 values : options. clone ( ) . into ( ) ,
252243 targets : target_blocks,
@@ -271,7 +262,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
271262 if let [ success, fail] = * make_target_blocks ( self ) {
272263 assert_eq ! ( value. ty, ty) ;
273264 let expect = self . literal_operand ( test. span , value) ;
274- let val = Operand :: Copy ( * place) ;
265+ let val = Operand :: Copy ( place) ;
275266 self . compare ( block, success, fail, source_info, BinOp :: Eq , expect, val) ;
276267 } else {
277268 bug ! ( "`TestKind::Eq` should have two target blocks" ) ;
@@ -286,7 +277,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
286277 // Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
287278 let lo = self . literal_operand ( test. span , lo) ;
288279 let hi = self . literal_operand ( test. span , hi) ;
289- let val = Operand :: Copy ( * place) ;
280+ let val = Operand :: Copy ( place) ;
290281
291282 if let [ success, fail] = * target_blocks {
292283 self . compare (
@@ -315,7 +306,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
315306 let actual = self . temp ( usize_ty, test. span ) ;
316307
317308 // 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) ) ;
319310
320311 // expected = <N>
321312 let expected = self . push_usize ( block, source_info, len) ;
@@ -371,13 +362,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
371362 make_target_blocks : impl FnOnce ( & mut Self ) -> Vec < BasicBlock > ,
372363 source_info : SourceInfo ,
373364 value : & ' tcx ty:: Const < ' tcx > ,
374- place : & Place < ' tcx > ,
365+ place : Place < ' tcx > ,
375366 mut ty : Ty < ' tcx > ,
376367 ) {
377368 use rustc:: middle:: lang_items:: EqTraitLangItem ;
378369
379370 let mut expect = self . literal_operand ( source_info. span , value) ;
380- let mut val = Operand :: Copy ( * place) ;
371+ let mut val = Operand :: Copy ( place) ;
381372
382373 // If we're using `b"..."` as a pattern, we need to insert an
383374 // unsizing coercion, as the byte string has the type `&[u8; N]`.
@@ -502,7 +493,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
502493 /// that it *doesn't* apply. For now, we return false, indicate that the
503494 /// test does not apply to this candidate, but it might be we can get
504495 /// tighter match code if we do something a bit different.
505- crate fn sort_candidate < ' pat > (
496+ pub ( super ) fn sort_candidate < ' pat > (
506497 & mut self ,
507498 test_place : & Place < ' tcx > ,
508499 test : & Test < ' tcx > ,
@@ -755,8 +746,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
755746 let downcast_place = tcx. mk_place_elem ( match_pair. place , elem) ; // `(x as Variant)`
756747 let consequent_match_pairs = subpatterns. iter ( ) . map ( |subpattern| {
757748 // 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 ) ;
760750 // e.g., `(x as Variant).0 @ P1`
761751 MatchPair :: new ( place, & subpattern. pattern )
762752 } ) ;
0 commit comments