@@ -105,25 +105,12 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
105
105
106
106
trace!("ConstProp starting for {:?}", def_id);
107
107
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
-
121
108
// FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold
122
109
// constants, instead of just checking for const-folding succeeding.
123
110
// That would require a uniform one-def no-mutation analysis
124
111
// 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);
127
114
128
115
trace!("ConstProp done for {:?}", def_id);
129
116
}
@@ -169,11 +156,7 @@ impl<'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'_, 'tcx> {
169
156
}
170
157
171
158
impl<'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> {
177
160
let def_id = body.source.def_id();
178
161
let args = &GenericArgs::identity_for_item(tcx, def_id);
179
162
let param_env = tcx.param_env_reveal_all_normalized(def_id);
@@ -204,7 +187,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
204
187
205
188
ecx.push_stack_frame(
206
189
Instance::new(def_id, args),
207
- dummy_body ,
190
+ body ,
208
191
&ret,
209
192
StackPopCleanup::Root { cleanup: false },
210
193
)
0 commit comments