Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc_mir/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down