Skip to content

Commit 7c9db32

Browse files
committed
Disallow casting directly between C-like enums and unsafe pointers
This closes issue #17444
1 parent 293b577 commit 7c9db32

File tree

1 file changed

+1
-1
lines changed
  • src/librustc/middle/typeck/check

1 file changed

+1
-1
lines changed

src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ fn check_cast(fcx: &FnCtxt,
14681468
// casts to scalars other than `char` and `bare fn` are trivial
14691469
let t_1_is_trivial = t_1_is_scalar && !t_1_is_char && !t_1_is_bare_fn;
14701470
if ty::type_is_c_like_enum(fcx.tcx(), t_e) && t_1_is_trivial {
1471-
if t_1_is_float {
1471+
if t_1_is_float || ty::type_is_unsafe_ptr(t_1) {
14721472
fcx.type_error_message(span, |actual| {
14731473
format!("illegal cast; cast through an \
14741474
integer first: `{}` as `{}`",

0 commit comments

Comments
 (0)