Skip to content

Commit 0a7202d

Browse files
committed
Change generator_drop's instance to that of generator for dump_mir
Otherwise the file name generated for generator_drop will become core.ptr-drop_in_place.[generator@<FILEPATH>_<NUMBERS>].generator_drop.0.mir instead of main-{closure#0}.generator_drop.0.mir which breaks a mir-opt test.
1 parent eb4d6d9 commit 0a7202d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compiler/rustc_mir_transform/src/generator.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,11 @@ fn create_generator_drop_shim<'tcx>(
11511151
simplify::remove_dead_blocks(tcx, &mut body);
11521152

11531153
// Update the body's def to become the drop glue.
1154+
// This needs to be updated before the AbortUnwindingCalls pass.
1155+
let gen_instance = body.source.instance;
11541156
let drop_in_place = tcx.require_lang_item(LangItem::DropInPlace, None);
1155-
body.source.instance = InstanceDef::DropGlue(drop_in_place, Some(gen_ty));
1157+
let drop_instance = InstanceDef::DropGlue(drop_in_place, Some(gen_ty));
1158+
body.source.instance = drop_instance;
11561159

11571160
pm::run_passes_no_validate(
11581161
tcx,
@@ -1161,7 +1164,11 @@ fn create_generator_drop_shim<'tcx>(
11611164
None,
11621165
);
11631166

1167+
// Temporary change MirSource to generator's instance so that dump_mir produces more sensible
1168+
// filename.
1169+
body.source.instance = gen_instance;
11641170
dump_mir(tcx, false, "generator_drop", &0, &body, |_, _| Ok(()));
1171+
body.source.instance = drop_instance;
11651172

11661173
body
11671174
}

0 commit comments

Comments
 (0)