@@ -196,20 +196,13 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
196196 block ( & mut blocks, TerminatorKind :: Goto { target : return_block } ) ;
197197 block ( & mut blocks, TerminatorKind :: Return ) ;
198198
199- let mut body = Body :: new (
200- blocks,
201- IndexVec :: from_elem_n (
202- SourceScopeData { span : span, parent_scope : None } , 1
203- ) ,
204- ClearCrossCrate :: Clear ,
205- local_decls_for_sig ( & sig, span) ,
206- IndexVec :: new ( ) ,
207- sig. inputs ( ) . len ( ) ,
208- vec ! [ ] ,
209- span,
210- vec ! [ ] ,
211- None ,
212- ) ;
199+ let mut body = new_body ( blocks,
200+ IndexVec :: from_elem_n (
201+ SourceScopeData { span, parent_scope : None } , 1
202+ ) ,
203+ local_decls_for_sig ( & sig, span) ,
204+ sig. inputs ( ) . len ( ) ,
205+ span) ;
213206
214207 if let Some ( ..) = ty {
215208 // The first argument (index 0), but add 1 for the return value.
@@ -248,6 +241,27 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
248241 body
249242}
250243
244+ fn new_body < ' tcx > ( basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
245+ source_scopes : IndexVec < SourceScope , SourceScopeData > ,
246+ local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
247+ arg_count : usize ,
248+ span : Span ,
249+ ) -> Body < ' tcx > {
250+ Body :: new (
251+ basic_blocks,
252+ source_scopes,
253+ ClearCrossCrate :: Clear ,
254+ None ,
255+ local_decls,
256+ IndexVec :: new ( ) ,
257+ arg_count,
258+ vec ! [ ] ,
259+ span,
260+ vec ! [ ] ,
261+ None ,
262+ )
263+ }
264+
251265pub struct DropShimElaborator < ' a , ' tcx > {
252266 pub body : & ' a Body < ' tcx > ,
253267 pub patch : MirPatch < ' tcx > ,
@@ -363,19 +377,13 @@ impl CloneShimBuilder<'tcx> {
363377 }
364378
365379 fn into_mir ( self ) -> Body < ' tcx > {
366- Body :: new (
367- self . blocks ,
368- IndexVec :: from_elem_n (
369- SourceScopeData { span : self . span , parent_scope : None } , 1
370- ) ,
371- ClearCrossCrate :: Clear ,
372- self . local_decls ,
373- IndexVec :: new ( ) ,
374- self . sig . inputs ( ) . len ( ) ,
375- vec ! [ ] ,
376- self . span ,
377- vec ! [ ] ,
378- None ,
380+ new_body ( self . blocks ,
381+ IndexVec :: from_elem_n (
382+ SourceScopeData { span : self . span , parent_scope : None } , 1
383+ ) ,
384+ self . local_decls ,
385+ self . sig . inputs ( ) . len ( ) ,
386+ self . span ,
379387 )
380388 }
381389
@@ -824,20 +832,16 @@ fn build_call_shim<'tcx>(
824832 block ( & mut blocks, vec ! [ ] , TerminatorKind :: Resume , true ) ;
825833 }
826834
827- let mut body = Body :: new (
835+ let mut body = new_body (
828836 blocks,
829837 IndexVec :: from_elem_n (
830- SourceScopeData { span : span , parent_scope : None } , 1
838+ SourceScopeData { span, parent_scope : None } , 1
831839 ) ,
832- ClearCrossCrate :: Clear ,
833840 local_decls,
834- IndexVec :: new ( ) ,
835841 sig. inputs ( ) . len ( ) ,
836- vec ! [ ] ,
837842 span,
838- vec ! [ ] ,
839- None ,
840843 ) ;
844+
841845 if let Abi :: RustCall = sig. abi {
842846 body. spread_arg = Some ( Local :: new ( sig. inputs ( ) . len ( ) ) ) ;
843847 }
@@ -911,19 +915,14 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> &Body<'_> {
911915 is_cleanup : false
912916 } ;
913917
914- let body = Body :: new (
918+ let body = new_body (
915919 IndexVec :: from_elem_n ( start_block, 1 ) ,
916920 IndexVec :: from_elem_n (
917- SourceScopeData { span : span , parent_scope : None } , 1
921+ SourceScopeData { span, parent_scope : None } , 1
918922 ) ,
919- ClearCrossCrate :: Clear ,
920923 local_decls,
921- IndexVec :: new ( ) ,
922924 sig. inputs ( ) . len ( ) ,
923- vec ! [ ] ,
924925 span,
925- vec ! [ ] ,
926- None ,
927926 ) ;
928927
929928 crate :: util:: dump_mir (
0 commit comments