Skip to content

Commit

Permalink
Clarify comment about _2 living across a yield
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Feb 6, 2020
1 parent 84dd07a commit 732913a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustc_mir/transform/generator.rs
Expand Up @@ -1187,8 +1187,9 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
let new_ret_local = replace_local(RETURN_PLACE, ret_ty, body, tcx);

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

0 comments on commit 732913a

Please sign in to comment.