mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
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`.
This commit is contained in:
parent
55f46419af
commit
18a21e13b4
@ -70,7 +70,6 @@ impl<'tcx, 'a> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'tcx, 'a> {
|
||||
build_ptr_tys(tcx, base_ty.boxed_ty(), self.unique_did, self.nonnull_did);
|
||||
|
||||
let ptr_local = self.patch.new_temp(ptr_ty, source_info.span);
|
||||
self.local_decls.push(LocalDecl::new(ptr_ty, source_info.span));
|
||||
|
||||
self.patch.add_statement(location, StatementKind::StorageLive(ptr_local));
|
||||
|
||||
@ -125,13 +124,6 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if let Some(terminator) = terminator
|
||||
&& !matches!(terminator.kind, TerminatorKind::Yield{..})
|
||||
{
|
||||
let location = Location { block, statement_index: index };
|
||||
visitor.visit_terminator(terminator, location);
|
||||
}
|
||||
|
||||
let location = Location { block, statement_index: index };
|
||||
match terminator {
|
||||
// yielding into a box is handled when lowering generators
|
||||
|
Loading…
Reference in New Issue
Block a user