Skip to content

Commit 732913a

Browse files
Clarify comment about _2 living across a yield
1 parent 84dd07a commit 732913a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/librustc_mir/transform/generator.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,9 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
11871187
let new_ret_local = replace_local(RETURN_PLACE, ret_ty, body, tcx);
11881188

11891189
// We also replace the resume argument and insert an `Assign`.
1190-
// This is needed because the resume argument might be live across a `yield`, and the
1191-
// transform assumes that any local live across a `yield` is assigned to before that.
1190+
// This is needed because the resume argument `_2` might be live across a `yield`, in which
1191+
// case there is no `Assign` to it that the transform can turn into a store to the generator
1192+
// state. After the yield the slot in the generator state would then be uninitialized.
11921193
let resume_local = Local::new(2);
11931194
let new_resume_local =
11941195
replace_local(resume_local, body.local_decls[resume_local].ty, body, tcx);

0 commit comments

Comments
 (0)