Skip to content

Commit 867af81

Browse files
author
Saleem Jaffer
committed
minor
1 parent 2e2f145 commit 867af81

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/librustc_passes/rvalue_promotion.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,16 @@ fn check_expr_kind<'a, 'tcx>(
319319
hir::ExprKind::Cast(ref from, _) => {
320320
let expr_promotability = v.check_expr(from);
321321
debug!("Checking const cast(id={})", from.hir_id);
322-
let cast_in = CastTy::from_ty(v.tables.expr_ty(from)).expect("bad input type for cast");
323-
match cast_in {
324-
CastTy::FnPtr | CastTy::Ptr(_) => {
325-
NotPromotable
326-
}
327-
_ => expr_promotability
322+
let cast_in = CastTy::from_ty(v.tables.expr_ty(from));
323+
let cast_out = CastTy::from_ty(v.tables.expr_ty(e));
324+
match (cast_in, cast_out) {
325+
(Some(CastTy::FnPtr), Some(CastTy::Int(_))) |
326+
(Some(CastTy::Ptr(_)), Some(CastTy::Int(_))) => NotPromotable,
327+
(None, _) => {
328+
//v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
329+
Promotable
330+
},
331+
(_, _) => expr_promotability
328332
}
329333
}
330334
hir::ExprKind::Path(ref qpath) => {

0 commit comments

Comments
 (0)