Skip to content

Commit 603a833

Browse files
committed
Temporary hack for 32959
Gets rid of the warning
1 parent 8da2bca commit 603a833

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/librustc_mir/build/block.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use rustc::hir;
1616
impl<'a,'tcx> Builder<'a,'tcx> {
1717
pub fn ast_block(&mut self,
1818
destination: &Lvalue<'tcx>,
19+
// FIXME(#32959): temporary measure for the issue
20+
dest_is_unit: bool,
1921
mut block: BasicBlock,
2022
ast_block: &'tcx hir::Block)
2123
-> BlockAnd<()> {
@@ -66,7 +68,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
6668
// of the block.
6769
if let Some(expr) = expr {
6870
unpack!(block = this.into(destination, block, expr));
69-
} else {
71+
} else if dest_is_unit {
7072
// FIXME(#31472)
7173
let scope_id = this.innermost_scope_id();
7274
this.cfg.push_assign_unit(block, scope_id, span, destination);

src/librustc_mir/build/expr/into.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
4040
this.in_scope(extent, block, |this, _| this.into(destination, block, value))
4141
}
4242
ExprKind::Block { body: ast_block } => {
43-
this.ast_block(destination, block, ast_block)
43+
this.ast_block(destination, expr.ty.is_nil(), block, ast_block)
4444
}
4545
ExprKind::Match { discriminant, arms } => {
4646
this.match_expr(destination, expr_span, block, discriminant, arms)

src/librustc_mir/build/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
200200
CodeExtentData::ParameterScope { fn_id: fn_id, body_id: body_id });
201201
unpack!(block = builder.in_scope(arg_extent, block, |builder, arg_scope_id| {
202202
arg_decls = Some(unpack!(block = builder.args_and_body(block,
203+
return_ty,
203204
implicit_arguments,
204205
explicit_arguments,
205206
arg_scope_id,
@@ -268,6 +269,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
268269
impl<'a,'tcx> Builder<'a,'tcx> {
269270
fn args_and_body(&mut self,
270271
mut block: BasicBlock,
272+
return_ty: FnOutput<'tcx>,
271273
implicit_arguments: Vec<Ty<'tcx>>,
272274
explicit_arguments: Vec<(Ty<'tcx>, &'tcx hir::Pat)>,
273275
argument_scope_id: ScopeId,
@@ -313,8 +315,14 @@ impl<'a,'tcx> Builder<'a,'tcx> {
313315
})
314316
.collect();
315317

318+
// FIXME(#32959): temporary hack for the issue at hand
319+
let return_is_unit = if let FnOutput::FnConverging(t) = return_ty {
320+
t.is_nil()
321+
} else {
322+
false
323+
};
316324
// start the first basic block and translate the body
317-
unpack!(block = self.ast_block(&Lvalue::ReturnPointer, block, ast_block));
325+
unpack!(block = self.ast_block(&Lvalue::ReturnPointer, return_is_unit, block, ast_block));
318326

319327
block.and(arg_decls)
320328
}

0 commit comments

Comments
 (0)