From d0086166b725d184b84b84b6270446998f6656cc Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Thu, 2 Apr 2020 10:54:24 -0700 Subject: [PATCH] Add `MutatingUseContext::Yield` ...emulating `MutatingUseContext::Call` --- src/librustc_codegen_ssa/mir/analyze.rs | 3 ++- src/librustc_middle/mir/visit.rs | 4 +++- src/librustc_mir/util/liveness.rs | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index a677ffea3af..9fcaf2818e8 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -269,7 +269,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> fn visit_local(&mut self, &local: &mir::Local, context: PlaceContext, location: Location) { match context { - PlaceContext::MutatingUse(MutatingUseContext::Call) => { + PlaceContext::MutatingUse(MutatingUseContext::Call) + | PlaceContext::MutatingUse(MutatingUseContext::Yield) => { self.assign(local, location); } diff --git a/src/librustc_middle/mir/visit.rs b/src/librustc_middle/mir/visit.rs index d32a8d43445..97f7cccdb60 100644 --- a/src/librustc_middle/mir/visit.rs +++ b/src/librustc_middle/mir/visit.rs @@ -510,7 +510,7 @@ macro_rules! make_mir_visitor { self.visit_operand(value, source_location); self.visit_place( resume_arg, - PlaceContext::MutatingUse(MutatingUseContext::Store), + PlaceContext::MutatingUse(MutatingUseContext::Yield), source_location, ); } @@ -1052,6 +1052,8 @@ pub enum MutatingUseContext { AsmOutput, /// Destination of a call. Call, + /// Destination of a yield. + Yield, /// Being dropped. Drop, /// Mutable borrow. diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index c6eefcc5eca..c261219cc73 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -133,6 +133,7 @@ pub fn categorize(context: PlaceContext) -> Option { // the def in call only to the input from the success // path and not the unwind path. -nmatsakis PlaceContext::MutatingUse(MutatingUseContext::Call) | + PlaceContext::MutatingUse(MutatingUseContext::Yield) | // Storage live and storage dead aren't proper defines, but we can ignore // values that come before them.