]> git.lizzy.rs Git - rust.git/commitdiff
Temporary hack for 32959
authorSimonas Kazlauskas <git@kazlauskas.me>
Fri, 29 Apr 2016 00:15:13 +0000 (03:15 +0300)
committerSimonas Kazlauskas <git@kazlauskas.me>
Fri, 29 Apr 2016 00:16:29 +0000 (03:16 +0300)
Gets rid of the warning

src/librustc_mir/build/block.rs
src/librustc_mir/build/expr/into.rs
src/librustc_mir/build/mod.rs

index 49029f9642e087c1655e7b12b2083a4f6dde6bc2..3bfea6149193faa05237426db144eb6df82d2b2d 100644 (file)
@@ -16,6 +16,8 @@
 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 @@ pub fn ast_block(&mut self,
             // 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);
index b7729b01737bad6628f5fbd22c76039aa603c92d..efffde9191008435b1c65d7b34671588fab7bde6 100644 (file)
@@ -40,7 +40,7 @@ pub fn into_expr(&mut self,
                 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)
index b088425d58a2a12fb4a7c0a96c1d434fc08c3936..1ed5fabf274a5accc67a3de3973f444d8110b999 100644 (file)
@@ -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 @@ fn args_and_body(&mut self,
             })
             .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)
     }