@@ -308,10 +308,8 @@ struct ConstPropagator<'mir, 'tcx> {
308308 ecx : InterpCx < ' mir , ' tcx , ConstPropMachine < ' mir , ' tcx > > ,
309309 tcx : TyCtxt < ' tcx > ,
310310 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 > > ,
315313 // Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store
316314 // the last known `SourceInfo` here and just keep revisiting it.
317315 source_info : Option < SourceInfo > ,
@@ -357,10 +355,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
357355 let substs = & InternalSubsts :: identity_for_item ( tcx, def_id) ;
358356 let param_env = tcx. param_env_reveal_all_normalized ( def_id) ;
359357
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.
364358 let can_const_prop = CanConstProp :: check ( tcx, param_env, body) ;
365359 let mut only_propagate_inside_block_locals = BitSet :: new_empty ( can_const_prop. len ( ) ) ;
366360 for ( l, mode) in can_const_prop. iter_enumerated ( ) {
@@ -370,7 +364,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
370364 }
371365 let mut ecx = InterpCx :: new (
372366 tcx,
373- span ,
367+ tcx . def_span ( def_id ) ,
374368 param_env,
375369 ConstPropMachine :: new ( only_propagate_inside_block_locals, can_const_prop) ,
376370 ) ;
@@ -401,11 +395,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
401395 ecx,
402396 tcx,
403397 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 ,
409400 source_info : None ,
410401 }
411402 }
@@ -435,7 +426,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
435426 }
436427
437428 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 )
439430 }
440431
441432 fn use_ecx < F , T > ( & mut self , f : F ) -> Option < T >
@@ -572,7 +563,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
572563 let r = r?;
573564 // We need the type of the LHS. We cannot use `place_layout` as that is the type
574565 // 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 ) ;
576567 let left_size = self . ecx . layout_of ( left_ty) . ok ( ) ?. size ;
577568 let right_size = r. layout . size ;
578569 let r_bits = r. to_scalar ( ) . ok ( ) ;
0 commit comments