Auto merge of #33267 - nagisa:mir-temporary-32959, r=nikomatsakis

[MIR] Temporary hack for 32959

Gets rid of the warning. This is more elegant that I thought it would be, actually.

r? @nikomatsakis

cc #32959
This commit is contained in:
bors 2016-05-06 18:15:39 -07:00
commit c95cda56a6
3 changed files with 13 additions and 3 deletions

View File

@ -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);

View File

@ -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)

View 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 @@ 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)
}