Skip to content

Commit 5777f2c

Browse files
committed
Auto merge of #117801 - tmiasko:remove-zsts-fuel, r=cjgillot
Remove incorrect transformation from RemoveZsts Partial removal of storage statements for a local is incorrect, so a decision to optimize cannot be make independently for each statement. Avoid the issue by performing the transformation completely or not at all.
2 parents d5375d0 + d7d2e76 commit 5777f2c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/rustc_mir_transform/src/remove_zsts.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ impl<'tcx> MirPass<'tcx> for RemoveZsts {
1717
if tcx.type_of(body.source.def_id()).instantiate_identity().is_coroutine() {
1818
return;
1919
}
20+
21+
if !tcx.consider_optimizing(|| format!("RemoveZsts - {:?}", body.source.def_id())) {
22+
return;
23+
}
24+
2025
let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id());
2126
let local_decls = &body.local_decls;
2227
let mut replacer = Replacer { tcx, param_env, local_decls };
@@ -125,12 +130,6 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
125130
if let Some(place_for_ty) = place_for_ty
126131
&& let ty = place_for_ty.ty(self.local_decls, self.tcx).ty
127132
&& self.known_to_be_zst(ty)
128-
&& self.tcx.consider_optimizing(|| {
129-
format!(
130-
"RemoveZsts - Place: {:?} SourceInfo: {:?}",
131-
place_for_ty, statement.source_info
132-
)
133-
})
134133
{
135134
statement.make_nop();
136135
} else {

0 commit comments

Comments
 (0)