File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff 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) => {
You can’t perform that action at this time.
0 commit comments