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:
commit
c95cda56a6
@ -16,6 +16,8 @@ use rustc::hir;
|
|||||||
impl<'a,'tcx> Builder<'a,'tcx> {
|
impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
pub fn ast_block(&mut self,
|
pub fn ast_block(&mut self,
|
||||||
destination: &Lvalue<'tcx>,
|
destination: &Lvalue<'tcx>,
|
||||||
|
// FIXME(#32959): temporary measure for the issue
|
||||||
|
dest_is_unit: bool,
|
||||||
mut block: BasicBlock,
|
mut block: BasicBlock,
|
||||||
ast_block: &'tcx hir::Block)
|
ast_block: &'tcx hir::Block)
|
||||||
-> BlockAnd<()> {
|
-> BlockAnd<()> {
|
||||||
@ -66,7 +68,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||||||
// of the block.
|
// of the block.
|
||||||
if let Some(expr) = expr {
|
if let Some(expr) = expr {
|
||||||
unpack!(block = this.into(destination, block, expr));
|
unpack!(block = this.into(destination, block, expr));
|
||||||
} else {
|
} else if dest_is_unit {
|
||||||
// FIXME(#31472)
|
// FIXME(#31472)
|
||||||
let scope_id = this.innermost_scope_id();
|
let scope_id = this.innermost_scope_id();
|
||||||
this.cfg.push_assign_unit(block, scope_id, span, destination);
|
this.cfg.push_assign_unit(block, scope_id, span, destination);
|
||||||
|
@ -40,7 +40,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||||||
this.in_scope(extent, block, |this, _| this.into(destination, block, value))
|
this.in_scope(extent, block, |this, _| this.into(destination, block, value))
|
||||||
}
|
}
|
||||||
ExprKind::Block { body: ast_block } => {
|
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 } => {
|
ExprKind::Match { discriminant, arms } => {
|
||||||
this.match_expr(destination, expr_span, block, discriminant, arms)
|
this.match_expr(destination, expr_span, block, discriminant, arms)
|
||||||
|
@ -200,6 +200,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
|
|||||||
CodeExtentData::ParameterScope { fn_id: fn_id, body_id: body_id });
|
CodeExtentData::ParameterScope { fn_id: fn_id, body_id: body_id });
|
||||||
unpack!(block = builder.in_scope(arg_extent, block, |builder, arg_scope_id| {
|
unpack!(block = builder.in_scope(arg_extent, block, |builder, arg_scope_id| {
|
||||||
arg_decls = Some(unpack!(block = builder.args_and_body(block,
|
arg_decls = Some(unpack!(block = builder.args_and_body(block,
|
||||||
|
return_ty,
|
||||||
implicit_arguments,
|
implicit_arguments,
|
||||||
explicit_arguments,
|
explicit_arguments,
|
||||||
arg_scope_id,
|
arg_scope_id,
|
||||||
@ -268,6 +269,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
|
|||||||
impl<'a,'tcx> Builder<'a,'tcx> {
|
impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
fn args_and_body(&mut self,
|
fn args_and_body(&mut self,
|
||||||
mut block: BasicBlock,
|
mut block: BasicBlock,
|
||||||
|
return_ty: FnOutput<'tcx>,
|
||||||
implicit_arguments: Vec<Ty<'tcx>>,
|
implicit_arguments: Vec<Ty<'tcx>>,
|
||||||
explicit_arguments: Vec<(Ty<'tcx>, &'tcx hir::Pat)>,
|
explicit_arguments: Vec<(Ty<'tcx>, &'tcx hir::Pat)>,
|
||||||
argument_scope_id: ScopeId,
|
argument_scope_id: ScopeId,
|
||||||
@ -313,8 +315,14 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||||||
})
|
})
|
||||||
.collect();
|
.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
|
// 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)
|
block.and(arg_decls)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user