Disallow casting directly between C-like enums and unsafe pointers

This closes issue #17444
This commit is contained in:
Brian Koropoff 2014-09-30 19:48:17 -07:00
parent 293b57701b
commit 7c9db32f82

View file

@ -1468,7 +1468,7 @@ fn check_cast(fcx: &FnCtxt,
// casts to scalars other than `char` and `bare fn` are trivial
let t_1_is_trivial = t_1_is_scalar && !t_1_is_char && !t_1_is_bare_fn;
if ty::type_is_c_like_enum(fcx.tcx(), t_e) && t_1_is_trivial {
if t_1_is_float {
if t_1_is_float || ty::type_is_unsafe_ptr(t_1) {
fcx.type_error_message(span, |actual| {
format!("illegal cast; cast through an \
integer first: `{}` as `{}`",