diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-04-03 16:37:54 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-04-03 16:37:54 +0200 |
| commit | f65e26eeee900a0f2f460631ac58086190ce6a4a (patch) | |
| tree | c1651baf8abec084b7570bd15f60a61e611fea48 /src/rustc | |
| parent | 90d3f0fb5e8512a3024a7ece53c8c200e8e12e28 (diff) | |
| download | rust-f65e26eeee900a0f2f460631ac58086190ce6a4a.tar.gz rust-f65e26eeee900a0f2f460631ac58086190ce6a4a.zip | |
Output type sizes in reinterpret_cast error message
Closes #2095
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/middle/trans/native.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/rustc/middle/trans/native.rs b/src/rustc/middle/trans/native.rs index 84486898fba..d8ab88e04ee 100644 --- a/src/rustc/middle/trans/native.rs +++ b/src/rustc/middle/trans/native.rs @@ -780,15 +780,17 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item, "forget" {} "reinterpret_cast" { let llout_ty = type_of::type_of(ccx, substs.tys[1]); - if shape::llsize_of_real(ccx, lltp_ty) != - shape::llsize_of_real(ccx, llout_ty) { + let tp_sz = shape::llsize_of_real(ccx, lltp_ty), + out_sz = shape::llsize_of_real(ccx, llout_ty); + if tp_sz != out_sz { let sp = alt check ccx.tcx.items.get(option::get(ref_id)) { ast_map::node_expr(e) { e.span } }; - ccx.sess.span_fatal(sp, "reinterpret_cast called on types \ - with different size: " + - ty_to_str(ccx.tcx, tp_ty) + " to " + - ty_to_str(ccx.tcx, substs.tys[1])); + ccx.sess.span_fatal( + sp, #fmt("reinterpret_cast called on types \ + with different size: %s (%u) to %s (%u)", + ty_to_str(ccx.tcx, tp_ty), tp_sz, + ty_to_str(ccx.tcx, substs.tys[1]), out_sz)); } if !ty::type_is_nil(substs.tys[1]) { let cast = PointerCast(bcx, get_param(decl, first_real_arg), |
