Rollup merge of #58670 - saleemjaffer:refactor_typecast_check_kinds, r=oli-obk
fixes rust-lang#52482
This commit is contained in:
commit
0c4cb48e03
5 changed files with 32 additions and 47 deletions
|
|
@ -14,7 +14,7 @@
|
|||
// - It's not possible to take the address of a static item with unsafe interior. This is enforced
|
||||
// by borrowck::gather_loans
|
||||
|
||||
use rustc::ty::cast::CastKind;
|
||||
use rustc::ty::cast::CastTy;
|
||||
use rustc::hir::def::{Def, CtorKind};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::middle::expr_use_visitor as euv;
|
||||
|
|
@ -318,15 +318,12 @@ 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);
|
||||
match v.tables.cast_kinds().get(from.hir_id) {
|
||||
None => {
|
||||
v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
|
||||
NotPromotable
|
||||
},
|
||||
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
|
||||
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,
|
||||
(_, _) => expr_promotability
|
||||
}
|
||||
}
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue