Skip to content

Commit ccc5e07

Browse files
committed
mir: Ignore noop casts (e.g. when as used for coercion).
1 parent 1de6a96 commit ccc5e07

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/librustc_mir/build/expr/as_rvalue.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@ impl<'a,'tcx> Builder<'a,'tcx> {
7373
})
7474
}
7575
ExprKind::Cast { source } => {
76-
let source = unpack!(block = this.as_operand(block, source));
77-
block.and(Rvalue::Cast(CastKind::Misc, source, expr.ty))
76+
let source = this.hir.mirror(source);
77+
if source.ty == expr.ty {
78+
this.expr_as_rvalue(block, source)
79+
} else {
80+
let source = unpack!(block = this.as_operand(block, source));
81+
block.and(Rvalue::Cast(CastKind::Misc, source, expr.ty))
82+
}
7883
}
7984
ExprKind::ReifyFnPointer { source } => {
8085
let source = unpack!(block = this.as_operand(block, source));

0 commit comments

Comments
 (0)