From 2624772c68de962d44fa6a1bb879578ef2488796 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 10 Oct 2015 23:21:08 +0200 Subject: [PATCH 1/3] Improve E0512 error message --- src/librustc_trans/trans/intrinsic.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 0573d6301c5..5e781bdf330 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -135,7 +135,7 @@ pub fn check_intrinsics(ccx: &CrateContext) { if transmute_restriction.original_from != transmute_restriction.substituted_from { span_transmute_size_error(ccx.sess(), transmute_restriction.span, - &format!("transmute called on types with potentially different sizes: \ + &format!("transmute called with differently sized types: \ {} (could be {} bit{}) to {} (could be {} bit{})", transmute_restriction.original_from, from_type_size as usize, @@ -145,7 +145,7 @@ pub fn check_intrinsics(ccx: &CrateContext) { if to_type_size == 1 {""} else {"s"})); } else { span_transmute_size_error(ccx.sess(), transmute_restriction.span, - &format!("transmute called on types with different sizes: \ + &format!("transmute called with differently sized types: \ {} ({} bit{}) to {} ({} bit{})", transmute_restriction.original_from, from_type_size as usize, From 35f8184f7dde2373f9941f930ed99a59b35a26f9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 13 Oct 2015 10:25:31 +0200 Subject: [PATCH 2/3] Update test error compilation message for E0512 --- src/test/compile-fail/transmute-fat-pointers.rs | 8 ++++---- src/test/compile-fail/transmute-impl.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/compile-fail/transmute-fat-pointers.rs b/src/test/compile-fail/transmute-fat-pointers.rs index 31456853e1c..f7324247f3b 100644 --- a/src/test/compile-fail/transmute-fat-pointers.rs +++ b/src/test/compile-fail/transmute-fat-pointers.rs @@ -15,11 +15,11 @@ use std::mem::transmute; fn a(x: &[T]) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes + unsafe { transmute(x) } //~ ERROR transmute called with differently sized types } fn b(x: &T) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes + unsafe { transmute(x) } //~ ERROR transmute called with differently sized types } fn c(x: &T) -> &U { @@ -31,11 +31,11 @@ fn d(x: &[T]) -> &[U] { } fn e(x: &T) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes + unsafe { transmute(x) } //~ ERROR transmute called with differently sized types } fn f(x: &T) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes + unsafe { transmute(x) } //~ ERROR transmute called with differently sized types } fn main() { } diff --git a/src/test/compile-fail/transmute-impl.rs b/src/test/compile-fail/transmute-impl.rs index a77a37a77e1..55cebbd6cfc 100644 --- a/src/test/compile-fail/transmute-impl.rs +++ b/src/test/compile-fail/transmute-impl.rs @@ -26,7 +26,7 @@ impl Foo { fn n(x: &T) -> &isize { // Not OK here, because T : Sized is not in scope. - unsafe { transmute(x) } //~ ERROR transmute called on types with potentially different sizes + unsafe { transmute(x) } //~ ERROR transmute called with differently sized types } } From a3f9fc69d6e9fe3e3c3fd0f1e69ddd9733a2e05b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 16 Oct 2015 10:59:04 +0200 Subject: [PATCH 3/3] Change error message in rustbook --- src/doc/trpl/casting-between-types.md | 2 +- src/test/compile-fail/packed-struct-generic-transmute.rs | 2 +- src/test/compile-fail/packed-struct-transmute.rs | 2 +- src/test/compile-fail/transmute-different-sizes.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/trpl/casting-between-types.md b/src/doc/trpl/casting-between-types.md index dbacd405065..148c55e4b97 100644 --- a/src/doc/trpl/casting-between-types.md +++ b/src/doc/trpl/casting-between-types.md @@ -82,7 +82,7 @@ unsafe { with: ```text -error: transmute called on types with different sizes: [u8; 4] (32 bits) to u64 +error: transmute called with differently sized types: [u8; 4] (32 bits) to u64 (64 bits) ``` diff --git a/src/test/compile-fail/packed-struct-generic-transmute.rs b/src/test/compile-fail/packed-struct-generic-transmute.rs index 82425d2c227..2c345e6c8ab 100644 --- a/src/test/compile-fail/packed-struct-generic-transmute.rs +++ b/src/test/compile-fail/packed-struct-generic-transmute.rs @@ -13,7 +13,7 @@ // the error points to the start of the file, not the line with the // transmute -// error-pattern: transmute called on types with different size +// error-pattern: transmute called with differently sized types use std::mem; diff --git a/src/test/compile-fail/packed-struct-transmute.rs b/src/test/compile-fail/packed-struct-transmute.rs index 1b164709ac7..94f2522f3eb 100644 --- a/src/test/compile-fail/packed-struct-transmute.rs +++ b/src/test/compile-fail/packed-struct-transmute.rs @@ -13,7 +13,7 @@ // the error points to the start of the file, not the line with the // transmute -// error-pattern: transmute called on types with different size +// error-pattern: transmute called with differently sized types use std::mem; diff --git a/src/test/compile-fail/transmute-different-sizes.rs b/src/test/compile-fail/transmute-different-sizes.rs index 918589b8fd3..df87a7bbdc9 100644 --- a/src/test/compile-fail/transmute-different-sizes.rs +++ b/src/test/compile-fail/transmute-different-sizes.rs @@ -16,12 +16,12 @@ use std::mem::transmute; unsafe fn f() { let _: i8 = transmute(16i16); - //~^ ERROR transmute called on types with different sizes + //~^ ERROR transmute called with differently sized types } unsafe fn g(x: &T) { let _: i8 = transmute(x); - //~^ ERROR transmute called on types with potentially different sizes + //~^ ERROR transmute called with differently sized types } fn main() {}