Skip to content

Commit f65e26e

Browse files
committed
Output type sizes in reinterpret_cast error message
Closes #2095
1 parent 90d3f0f commit f65e26e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/rustc/middle/trans/native.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,15 +780,17 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
780780
"forget" {}
781781
"reinterpret_cast" {
782782
let llout_ty = type_of::type_of(ccx, substs.tys[1]);
783-
if shape::llsize_of_real(ccx, lltp_ty) !=
784-
shape::llsize_of_real(ccx, llout_ty) {
783+
let tp_sz = shape::llsize_of_real(ccx, lltp_ty),
784+
out_sz = shape::llsize_of_real(ccx, llout_ty);
785+
if tp_sz != out_sz {
785786
let sp = alt check ccx.tcx.items.get(option::get(ref_id)) {
786787
ast_map::node_expr(e) { e.span }
787788
};
788-
ccx.sess.span_fatal(sp, "reinterpret_cast called on types \
789-
with different size: " +
790-
ty_to_str(ccx.tcx, tp_ty) + " to " +
791-
ty_to_str(ccx.tcx, substs.tys[1]));
789+
ccx.sess.span_fatal(
790+
sp, #fmt("reinterpret_cast called on types \
791+
with different size: %s (%u) to %s (%u)",
792+
ty_to_str(ccx.tcx, tp_ty), tp_sz,
793+
ty_to_str(ccx.tcx, substs.tys[1]), out_sz));
792794
}
793795
if !ty::type_is_nil(substs.tys[1]) {
794796
let cast = PointerCast(bcx, get_param(decl, first_real_arg),

0 commit comments

Comments
 (0)