Skip to content

Improve E0512 error message #28957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/trpl/casting-between-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/trans/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/packed-struct-generic-transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/packed-struct-transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/transmute-different-sizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(x: &T) {
let _: i8 = transmute(x);
//~^ ERROR transmute called on types with potentially different sizes
//~^ ERROR transmute called with differently sized types
}

fn main() {}
8 changes: 4 additions & 4 deletions src/test/compile-fail/transmute-fat-pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
use std::mem::transmute;

fn a<T, U: ?Sized>(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<T: ?Sized, U: ?Sized>(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<T, U>(x: &T) -> &U {
Expand All @@ -31,11 +31,11 @@ fn d<T, U>(x: &[T]) -> &[U] {
}

fn e<T: ?Sized, U>(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<T, U: ?Sized>(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() { }
2 changes: 1 addition & 1 deletion src/test/compile-fail/transmute-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<T: ?Sized> Foo<T> {

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
}
}

Expand Down