Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Saleem Jaffer committed Mar 2, 2019
1 parent 2e2f145 commit 867af81
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/librustc_passes/rvalue_promotion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,16 @@ fn check_expr_kind<'a, 'tcx>(
hir::ExprKind::Cast(ref from, _) => {
let expr_promotability = v.check_expr(from);
debug!("Checking const cast(id={})", from.hir_id);
let cast_in = CastTy::from_ty(v.tables.expr_ty(from)).expect("bad input type for cast");
match cast_in {
CastTy::FnPtr | CastTy::Ptr(_) => {
NotPromotable
}
_ => expr_promotability
let cast_in = CastTy::from_ty(v.tables.expr_ty(from));
let cast_out = CastTy::from_ty(v.tables.expr_ty(e));
match (cast_in, cast_out) {
(Some(CastTy::FnPtr), Some(CastTy::Int(_))) |
(Some(CastTy::Ptr(_)), Some(CastTy::Int(_))) => NotPromotable,
(None, _) => {
//v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
Promotable
},
(_, _) => expr_promotability
}
}
hir::ExprKind::Path(ref qpath) => {
Expand Down

0 comments on commit 867af81

Please sign in to comment.