From f65e26eeee900a0f2f460631ac58086190ce6a4a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 3 Apr 2012 16:37:54 +0200 Subject: [PATCH] Output type sizes in reinterpret_cast error message Closes #2095 --- src/rustc/middle/trans/native.rs | 14 ++++++++------ 1 file 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),