@@ -35,6 +35,9 @@ use rustc_middle::mir::*;
3535use rustc_middle:: ty:: { self , DebruijnIndex , TyS , TypeFlags } ;
3636use rustc_span:: { self , BytePos , Pos , Span , DUMMY_SP } ;
3737
38+ // All `TEMP_BLOCK` targets should be replaced before calling `to_body() -> mir::Body`.
39+ const TEMP_BLOCK : BasicBlock = BasicBlock :: MAX ;
40+
3841fn dummy_ty ( ) -> & ' static TyS < ' static > {
3942 thread_local ! {
4043 static DUMMY_TYS : & ' static TyS <' static > = Box :: leak( box TyS :: make_for_test(
@@ -123,7 +126,7 @@ impl<'tcx> MockBlocks<'tcx> {
123126 if branch_index > branches. len ( ) {
124127 branches. push ( ( branches. len ( ) as u128 , old_otherwise) ) ;
125128 while branches. len ( ) < branch_index {
126- branches. push ( ( branches. len ( ) as u128 , START_BLOCK ) ) ;
129+ branches. push ( ( branches. len ( ) as u128 , TEMP_BLOCK ) ) ;
127130 }
128131 to_block
129132 } else {
@@ -143,7 +146,7 @@ impl<'tcx> MockBlocks<'tcx> {
143146 TerminatorKind :: Call {
144147 func : Operand :: Copy ( self . dummy_place . clone ( ) ) ,
145148 args : vec ! [ ] ,
146- destination : Some ( ( self . dummy_place . clone ( ) , START_BLOCK ) ) ,
149+ destination : Some ( ( self . dummy_place . clone ( ) , TEMP_BLOCK ) ) ,
147150 cleanup : None ,
148151 from_hir_call : false ,
149152 fn_span : DUMMY_SP ,
@@ -152,16 +155,14 @@ impl<'tcx> MockBlocks<'tcx> {
152155 }
153156
154157 fn goto ( & mut self , some_from_block : Option < BasicBlock > ) -> BasicBlock {
155- self . add_block_from ( some_from_block, TerminatorKind :: Goto { target : START_BLOCK } )
158+ self . add_block_from ( some_from_block, TerminatorKind :: Goto { target : TEMP_BLOCK } )
156159 }
157160
158161 fn switchint ( & mut self , some_from_block : Option < BasicBlock > ) -> BasicBlock {
159- let move_ = |place : Place < ' tcx > | Operand :: Move ( place) ;
160- let discriminant = Place :: from ( self . new_temp ( ) ) ;
161162 let switchint_kind = TerminatorKind :: SwitchInt {
162- discr : move_ ( discriminant ) ,
163+ discr : Operand :: Move ( Place :: from ( self . new_temp ( ) ) ) ,
163164 switch_ty : dummy_ty ( ) ,
164- targets : SwitchTargets :: static_if ( 0 , START_BLOCK , START_BLOCK ) ,
165+ targets : SwitchTargets :: static_if ( 0 , TEMP_BLOCK , TEMP_BLOCK ) ,
165166 } ;
166167 self . add_block_from ( some_from_block, switchint_kind)
167168 }
0 commit comments