@@ -308,10 +308,8 @@ struct ConstPropagator<'mir, 'tcx> {
308
308
ecx : InterpCx < ' mir , ' tcx , ConstPropMachine < ' mir , ' tcx > > ,
309
309
tcx : TyCtxt < ' tcx > ,
310
310
param_env : ParamEnv < ' tcx > ,
311
- // FIXME(eddyb) avoid cloning these two fields more than once,
312
- // by accessing them through `ecx` instead.
313
- source_scopes : IndexVec < SourceScope , SourceScopeData < ' tcx > > ,
314
- local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
311
+ source_scopes : & ' mir IndexVec < SourceScope , SourceScopeData < ' tcx > > ,
312
+ local_decls : & ' mir IndexVec < Local , LocalDecl < ' tcx > > ,
315
313
// Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store
316
314
// the last known `SourceInfo` here and just keep revisiting it.
317
315
source_info : Option < SourceInfo > ,
@@ -357,10 +355,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
357
355
let substs = & InternalSubsts :: identity_for_item ( tcx, def_id) ;
358
356
let param_env = tcx. param_env_reveal_all_normalized ( def_id) ;
359
357
360
- let span = tcx. def_span ( def_id) ;
361
- // FIXME: `CanConstProp::check` computes the layout of all locals, return those layouts
362
- // so we can write them to `ecx.frame_mut().locals.layout, reducing the duplication in
363
- // `layout_of` query invocations.
364
358
let can_const_prop = CanConstProp :: check ( tcx, param_env, body) ;
365
359
let mut only_propagate_inside_block_locals = BitSet :: new_empty ( can_const_prop. len ( ) ) ;
366
360
for ( l, mode) in can_const_prop. iter_enumerated ( ) {
@@ -370,7 +364,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
370
364
}
371
365
let mut ecx = InterpCx :: new (
372
366
tcx,
373
- span ,
367
+ tcx . def_span ( def_id ) ,
374
368
param_env,
375
369
ConstPropMachine :: new ( only_propagate_inside_block_locals, can_const_prop) ,
376
370
) ;
@@ -401,11 +395,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
401
395
ecx,
402
396
tcx,
403
397
param_env,
404
- // FIXME(eddyb) avoid cloning these two fields more than once,
405
- // by accessing them through `ecx` instead.
406
- source_scopes : body. source_scopes . clone ( ) ,
407
- //FIXME(wesleywiser) we can't steal this because `Visitor::super_visit_body()` needs it
408
- local_decls : body. local_decls . clone ( ) ,
398
+ source_scopes : & dummy_body. source_scopes ,
399
+ local_decls : & dummy_body. local_decls ,
409
400
source_info : None ,
410
401
}
411
402
}
@@ -435,7 +426,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
435
426
}
436
427
437
428
fn lint_root ( & self , source_info : SourceInfo ) -> Option < HirId > {
438
- source_info. scope . lint_root ( & self . source_scopes )
429
+ source_info. scope . lint_root ( self . source_scopes )
439
430
}
440
431
441
432
fn use_ecx < F , T > ( & mut self , f : F ) -> Option < T >
@@ -572,7 +563,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
572
563
let r = r?;
573
564
// We need the type of the LHS. We cannot use `place_layout` as that is the type
574
565
// of the result, which for checked binops is not the same!
575
- let left_ty = left. ty ( & self . local_decls , self . tcx ) ;
566
+ let left_ty = left. ty ( self . local_decls , self . tcx ) ;
576
567
let left_size = self . ecx . layout_of ( left_ty) . ok ( ) ?. size ;
577
568
let right_size = r. layout . size ;
578
569
let r_bits = r. to_scalar ( ) . ok ( ) ;
0 commit comments