@@ -105,25 +105,12 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
105105
106106 trace ! ( "ConstProp starting for {:?}" , def_id) ;
107107
108- let dummy_body = & Body :: new (
109- body. source ,
110- ( * body. basic_blocks ) . to_owned ( ) ,
111- body. source_scopes . clone ( ) ,
112- body. local_decls . clone ( ) ,
113- Default :: default ( ) ,
114- body. arg_count ,
115- Default :: default ( ) ,
116- body. span ,
117- body. generator_kind ( ) ,
118- body. tainted_by_errors ,
119- ) ;
120-
121108 // FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold
122109 // constants, instead of just checking for const-folding succeeding.
123110 // That would require a uniform one-def no-mutation analysis
124111 // and RPO (or recursing when needing the value of a local).
125- let mut optimization_finder = ConstPropagator :: new ( body, dummy_body , tcx) ;
126- optimization_finder . visit_body ( body) ;
112+ let mut linter = ConstPropagator :: new ( body, tcx) ;
113+ linter . visit_body ( body) ;
127114
128115 trace ! ( "ConstProp done for {:?}" , def_id) ;
129116 }
@@ -169,11 +156,7 @@ impl<'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'_, 'tcx> {
169156}
170157
171158impl < ' mir , ' tcx > ConstPropagator < ' mir , ' tcx > {
172- fn new (
173- body : & Body < ' tcx > ,
174- dummy_body : & ' mir Body < ' tcx > ,
175- tcx : TyCtxt < ' tcx > ,
176- ) -> ConstPropagator < ' mir , ' tcx > {
159+ fn new ( body : & ' mir Body < ' tcx > , tcx : TyCtxt < ' tcx > ) -> ConstPropagator < ' mir , ' tcx > {
177160 let def_id = body. source . def_id ( ) ;
178161 let args = & GenericArgs :: identity_for_item ( tcx, def_id) ;
179162 let param_env = tcx. param_env_reveal_all_normalized ( def_id) ;
@@ -204,7 +187,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
204187
205188 ecx. push_stack_frame (
206189 Instance :: new ( def_id, args) ,
207- dummy_body ,
190+ body ,
208191 & ret,
209192 StackPopCleanup :: Root { cleanup : false } ,
210193 )
0 commit comments