Skip to content

Commit 18a21e1

Browse files
committed
Remove duplicated temporaries creating during box derefs elaboration
Temporaries created with `MirPatch::new_temp` will be declared after patch application. Remove manually created duplicate declarations. Removing duplicates exposes another issue. Visitor elaborates terminator twice and attempts to access new, but not yet available, local declarations. Remove duplicated call to `visit_terminator`.
1 parent 55f4641 commit 18a21e1

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

compiler/rustc_mir_transform/src/elaborate_box_derefs.rs

-8
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ impl<'tcx, 'a> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'tcx, 'a> {
7070
build_ptr_tys(tcx, base_ty.boxed_ty(), self.unique_did, self.nonnull_did);
7171

7272
let ptr_local = self.patch.new_temp(ptr_ty, source_info.span);
73-
self.local_decls.push(LocalDecl::new(ptr_ty, source_info.span));
7473

7574
self.patch.add_statement(location, StatementKind::StorageLive(ptr_local));
7675

@@ -125,13 +124,6 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
125124
index += 1;
126125
}
127126

128-
if let Some(terminator) = terminator
129-
&& !matches!(terminator.kind, TerminatorKind::Yield{..})
130-
{
131-
let location = Location { block, statement_index: index };
132-
visitor.visit_terminator(terminator, location);
133-
}
134-
135127
let location = Location { block, statement_index: index };
136128
match terminator {
137129
// yielding into a box is handled when lowering generators

0 commit comments

Comments
 (0)