about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2016-04-29 03:15:13 +0300
committerSimonas Kazlauskas <git@kazlauskas.me>2016-04-29 03:16:29 +0300
commit603a8334804be0f09c22bcb8dc5ddf427cc220ae (patch)
treebddd79ef59a70a031485cabb1533883b580b7e66
parent8da2bcac5db1e091b90cceb19d0496f0f7501c88 (diff)
downloadrust-603a8334804be0f09c22bcb8dc5ddf427cc220ae.tar.gz
rust-603a8334804be0f09c22bcb8dc5ddf427cc220ae.zip
Temporary hack for 32959
Gets rid of the warning
-rw-r--r--src/librustc_mir/build/block.rs4
-rw-r--r--src/librustc_mir/build/expr/into.rs2
-rw-r--r--src/librustc_mir/build/mod.rs10
3 files changed, 13 insertions, 3 deletions
diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs
index 49029f9642e..3bfea614919 100644
--- a/src/librustc_mir/build/block.rs
+++ b/src/librustc_mir/build/block.rs
@@ -16,6 +16,8 @@ use rustc::hir;
 impl<'a,'tcx> Builder<'a,'tcx> {
     pub fn ast_block(&mut self,
                      destination: &Lvalue<'tcx>,
+                     // FIXME(#32959): temporary measure for the issue
+                     dest_is_unit: bool,
                      mut block: BasicBlock,
                      ast_block: &'tcx hir::Block)
                      -> BlockAnd<()> {
@@ -66,7 +68,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
             // of the block.
             if let Some(expr) = expr {
                 unpack!(block = this.into(destination, block, expr));
-            } else {
+            } else if dest_is_unit {
                 // FIXME(#31472)
                 let scope_id = this.innermost_scope_id();
                 this.cfg.push_assign_unit(block, scope_id, span, destination);
diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs
index b7729b01737..efffde91910 100644
--- a/src/librustc_mir/build/expr/into.rs
+++ b/src/librustc_mir/build/expr/into.rs
@@ -40,7 +40,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
                 this.in_scope(extent, block, |this, _| this.into(destination, block, value))
             }
             ExprKind::Block { body: ast_block } => {
-                this.ast_block(destination, block, ast_block)
+                this.ast_block(destination, expr.ty.is_nil(), block, ast_block)
             }
             ExprKind::Match { discriminant, arms } => {
                 this.match_expr(destination, expr_span, block, discriminant, arms)
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index b088425d58a..1ed5fabf274 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -200,6 +200,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
                 CodeExtentData::ParameterScope { fn_id: fn_id, body_id: body_id });
         unpack!(block = builder.in_scope(arg_extent, block, |builder, arg_scope_id| {
             arg_decls = Some(unpack!(block = builder.args_and_body(block,
+                                                                   return_ty,
                                                                    implicit_arguments,
                                                                    explicit_arguments,
                                                                    arg_scope_id,
@@ -268,6 +269,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
 impl<'a,'tcx> Builder<'a,'tcx> {
     fn args_and_body(&mut self,
                      mut block: BasicBlock,
+                     return_ty: FnOutput<'tcx>,
                      implicit_arguments: Vec<Ty<'tcx>>,
                      explicit_arguments: Vec<(Ty<'tcx>, &'tcx hir::Pat)>,
                      argument_scope_id: ScopeId,
@@ -313,8 +315,14 @@ impl<'a,'tcx> Builder<'a,'tcx> {
             })
             .collect();
 
+        // FIXME(#32959): temporary hack for the issue at hand
+        let return_is_unit = if let FnOutput::FnConverging(t) = return_ty {
+            t.is_nil()
+        } else {
+            false
+        };
         // start the first basic block and translate the body
-        unpack!(block = self.ast_block(&Lvalue::ReturnPointer, block, ast_block));
+        unpack!(block = self.ast_block(&Lvalue::ReturnPointer, return_is_unit, block, ast_block));
 
         block.and(arg_decls)
     }