diff options
| author | Brian Koropoff <bkoropoff@gmail.com> | 2014-09-30 19:48:17 -0700 |
|---|---|---|
| committer | Brian Koropoff <bkoropoff@gmail.com> | 2014-09-30 20:07:09 -0700 |
| commit | 7c9db32f828729a415f4c334cb69f485e3b84d3d (patch) | |
| tree | 28ffedd55d1e94d477939970b7a566666442dd3c | |
| parent | 293b57701b7bcdd88e44ce8f671511ba35cac13e (diff) | |
| download | rust-7c9db32f828729a415f4c334cb69f485e3b84d3d.tar.gz rust-7c9db32f828729a415f4c334cb69f485e3b84d3d.zip | |
Disallow casting directly between C-like enums and unsafe pointers
This closes issue #17444
| -rw-r--r-- | src/librustc/middle/typeck/check/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index d4c38d48a8c..c051782a83b 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -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 `{}`", |
