@@ -196,20 +196,13 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
196
196
block ( & mut blocks, TerminatorKind :: Goto { target : return_block } ) ;
197
197
block ( & mut blocks, TerminatorKind :: Return ) ;
198
198
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) ;
213
206
214
207
if let Some ( ..) = ty {
215
208
// 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>>)
248
241
body
249
242
}
250
243
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
+
251
265
pub struct DropShimElaborator < ' a , ' tcx > {
252
266
pub body : & ' a Body < ' tcx > ,
253
267
pub patch : MirPatch < ' tcx > ,
@@ -363,19 +377,13 @@ impl CloneShimBuilder<'tcx> {
363
377
}
364
378
365
379
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 ,
379
387
)
380
388
}
381
389
@@ -824,20 +832,16 @@ fn build_call_shim<'tcx>(
824
832
block ( & mut blocks, vec ! [ ] , TerminatorKind :: Resume , true ) ;
825
833
}
826
834
827
- let mut body = Body :: new (
835
+ let mut body = new_body (
828
836
blocks,
829
837
IndexVec :: from_elem_n (
830
- SourceScopeData { span : span , parent_scope : None } , 1
838
+ SourceScopeData { span, parent_scope : None } , 1
831
839
) ,
832
- ClearCrossCrate :: Clear ,
833
840
local_decls,
834
- IndexVec :: new ( ) ,
835
841
sig. inputs ( ) . len ( ) ,
836
- vec ! [ ] ,
837
842
span,
838
- vec ! [ ] ,
839
- None ,
840
843
) ;
844
+
841
845
if let Abi :: RustCall = sig. abi {
842
846
body. spread_arg = Some ( Local :: new ( sig. inputs ( ) . len ( ) ) ) ;
843
847
}
@@ -911,19 +915,14 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> &Body<'_> {
911
915
is_cleanup : false
912
916
} ;
913
917
914
- let body = Body :: new (
918
+ let body = new_body (
915
919
IndexVec :: from_elem_n ( start_block, 1 ) ,
916
920
IndexVec :: from_elem_n (
917
- SourceScopeData { span : span , parent_scope : None } , 1
921
+ SourceScopeData { span, parent_scope : None } , 1
918
922
) ,
919
- ClearCrossCrate :: Clear ,
920
923
local_decls,
921
- IndexVec :: new ( ) ,
922
924
sig. inputs ( ) . len ( ) ,
923
- vec ! [ ] ,
924
925
span,
925
- vec ! [ ] ,
926
- None ,
927
926
) ;
928
927
929
928
crate :: util:: dump_mir (
0 commit comments