Put deaggregated statements after original constant.

This commit is contained in:
Camille GILLOT 2023-02-09 17:27:31 +00:00
parent 7ff69b49df
commit 221ea3080d
3 changed files with 57 additions and 0 deletions

View file

@ -318,6 +318,8 @@ impl<'tcx, 'll> MutVisitor<'tcx> for ReplacementVisitor<'tcx, 'll> {
// ConstProp will pick up the pieces and replace them by actual constants.
StatementKind::Assign(box (place, Rvalue::Use(Operand::Constant(_)))) => {
if let Some(final_locals) = self.replacements.place_fragments(place) {
// Put the deaggregated statements *after* the original one.
let location = location.successor_within_block();
for (field, ty, new_local) in final_locals {
let rplace = self.tcx.mk_place_field(place, field, ty);
let rvalue = Rvalue::Use(Operand::Move(rplace));