Skip to content

Commit 2e2f145

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

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Diff for: src/librustc_passes/rvalue_promotion.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// - It's not possible to take the address of a static item with unsafe interior. This is enforced
1515
// by borrowck::gather_loans
1616

17-
use rustc::ty::cast::CastKind;
17+
use rustc::ty::cast::CastTy;
1818
use rustc::hir::def::{Def, CtorKind};
1919
use rustc::hir::def_id::DefId;
2020
use rustc::middle::expr_use_visitor as euv;
@@ -319,12 +319,9 @@ 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-
match v.tables.cast_kinds().get(from.hir_id) {
323-
None => {
324-
v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
325-
NotPromotable
326-
},
327-
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
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(_) => {
328325
NotPromotable
329326
}
330327
_ => expr_promotability

0 commit comments

Comments
 (0)