]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_mir_build/build/expr/into.rs
New upstream version 1.43.0+dfsg1
[rustc.git] / src / librustc_mir_build / build / expr / into.rs
index 5ef338c624da26cff15e64d8af66010fcc64ec28..4583e244f493d7c904a7aa04aba91fcdac388d9c 100644 (file)
@@ -365,6 +365,24 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 block.unit()
             }
 
+            ExprKind::Yield { value } => {
+                let scope = this.local_scope();
+                let value = unpack!(block = this.as_operand(block, scope, value));
+                let resume = this.cfg.start_new_block();
+                let cleanup = this.generator_drop_cleanup();
+                this.cfg.terminate(
+                    block,
+                    source_info,
+                    TerminatorKind::Yield {
+                        value,
+                        resume,
+                        resume_arg: *destination,
+                        drop: cleanup,
+                    },
+                );
+                resume.unit()
+            }
+
             // these are the cases that are more naturally handled by some other mode
             ExprKind::Unary { .. }
             | ExprKind::Binary { .. }
@@ -376,8 +394,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             | ExprKind::Tuple { .. }
             | ExprKind::Closure { .. }
             | ExprKind::Literal { .. }
-            | ExprKind::StaticRef { .. }
-            | ExprKind::Yield { .. } => {
+            | ExprKind::StaticRef { .. } => {
                 debug_assert!(match Category::of(&expr.kind).unwrap() {
                     // should be handled above
                     Category::Rvalue(RvalueFunc::Into) => false,