From 732913afcbc37a061dfdc3097cbdc90823386c11 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 6 Feb 2020 12:34:31 +0100 Subject: [PATCH] Clarify comment about `_2` living across a yield --- src/librustc_mir/transform/generator.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 267e77ba48128..a6fc65731780a 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -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);