Skip to content
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

Improve E0512 error message #28957

Merged
merged 3 commits into from
Oct 16, 2015
Merged

Improve E0512 error message #28957

merged 3 commits into from
Oct 16, 2015

Conversation

GuillaumeGomez
Copy link
Member

cc @nagisa

@rust-highfive
Copy link
Collaborator

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -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 two differently sized types: \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading now, I’d remove the “two” actually, I think, since that’s implied both by the function signature and list of types that come after the colon.

@nagisa
Copy link
Member

nagisa commented Oct 10, 2015

Looks like an improvement to me.

@GuillaumeGomez
Copy link
Member Author

Updated !

#28909

@pnkfelix
Copy link
Member

@GuillaumeGomez why did you drop the word "potentially" ? Do you think it unnecessary?

@GuillaumeGomez
Copy link
Member Author

Then it would be a "potential" error, no? If the types did have the same size, either we'd have another error or it'd be just fine. I don't see other possibility here.

@pnkfelix
Copy link
Member

(I resolved my question with @GuillaumeGomez ; i had overlooked that this message is solely coming from trans, not the earlier type-checking where the sizes can be unknown.)

@pnkfelix
Copy link
Member

@bors r+

1 similar comment
@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 14, 2015

📌 Commit 35f8184 has been approved by pnkfelix

@bors
Copy link
Contributor

bors commented Oct 14, 2015

⌛ Testing commit 35f8184 with merge 40a1e4f...

@bors
Copy link
Contributor

bors commented Oct 14, 2015

💔 Test failed - auto-mac-64-opt

@Manishearth
Copy link
Member


failures:

---- [compile-fail] compile-fail/packed-struct-generic-transmute.rs stdout ----

error: error pattern ' transmute called on types with different size' not found!
status: exit code: 101
command: x86_64-apple-darwin/stage2/bin/rustc /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-generic-transmute.rs -L x86_64-apple-darwin/test/compile-fail/ --target=x86_64-apple-darwin -L x86_64-apple-darwin/test/compile-fail/packed-struct-generic-transmute.stage2-x86_64-apple-darwin.compile-fail.libaux -C prefer-dynamic -o x86_64-apple-darwin/test/compile-fail/packed-struct-generic-transmute.stage2-x86_64-apple-darwin --cfg rtopt -O -L x86_64-apple-darwin/rt
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-generic-transmute.rs:22:5: 22:11 warning: struct field is never used: `bar`, #[warn(dead_code)] on by default
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-generic-transmute.rs:22     bar: T,
                                                                                                                               ^~~~~~
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-generic-transmute.rs:23:5: 23:11 warning: struct field is never used: `baz`, #[warn(dead_code)] on by default
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-generic-transmute.rs:23     baz: S
                                                                                                                               ^~~~~~
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-generic-transmute.rs:34:38: 34:52 error: transmute called with differently sized types: Foo<[u8; 5], i32> (72 bits) to Oof<[u8; 5], i32> (96 bits) [E0512]
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-generic-transmute.rs:34         let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
                                                                                                                                                                ^~~~~~~~~~~~~~
error: aborting due to previous error

------------------------------------------

thread '[compile-fail] compile-fail/packed-struct-generic-transmute.rs' panicked at 'explicit panic', /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/compiletest/runtest.rs:1501

---- [compile-fail] compile-fail/packed-struct-transmute.rs stdout ----

error: error pattern ' transmute called on types with different size' not found!
status: exit code: 101
command: x86_64-apple-darwin/stage2/bin/rustc /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-transmute.rs -L x86_64-apple-darwin/test/compile-fail/ --target=x86_64-apple-darwin -L x86_64-apple-darwin/test/compile-fail/packed-struct-transmute.stage2-x86_64-apple-darwin.compile-fail.libaux -C prefer-dynamic -o x86_64-apple-darwin/test/compile-fail/packed-struct-transmute.stage2-x86_64-apple-darwin --cfg rtopt -O -L x86_64-apple-darwin/rt
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-transmute.rs:22:5: 22:12 warning: struct field is never used: `bar`, #[warn(dead_code)] on by default
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-transmute.rs:22     bar: u8,
                                                                                                                       ^~~~~~~
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-transmute.rs:23:5: 23:15 warning: struct field is never used: `baz`, #[warn(dead_code)] on by default
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-transmute.rs:23     baz: usize
                                                                                                                       ^~~~~~~~~~
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-transmute.rs:35:24: 35:38 error: transmute called with differently sized types: Foo (72 bits) to Oof (128 bits) [E0512]
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/packed-struct-transmute.rs:35         let oof: Oof = mem::transmute(foo);
                                                                                                                                          ^~~~~~~~~~~~~~
error: aborting due to previous error

------------------------------------------

thread '[compile-fail] compile-fail/packed-struct-transmute.rs' panicked at 'explicit panic', /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/compiletest/runtest.rs:1501

---- [compile-fail] compile-fail/transmute-different-sizes.rs stdout ----

error: unexpected compiler error or warning: '/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/transmute-different-sizes.rs:18:17: 18:26 error: transmute called with differently sized types: i16 (16 bits) to i8 (8 bits) [E0512]'
status: exit code: 101
command: x86_64-apple-darwin/stage2/bin/rustc /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/transmute-different-sizes.rs -L x86_64-apple-darwin/test/compile-fail/ --target=x86_64-apple-darwin -L x86_64-apple-darwin/test/compile-fail/transmute-different-sizes.stage2-x86_64-apple-darwin.compile-fail.libaux -C prefer-dynamic -o x86_64-apple-darwin/test/compile-fail/transmute-different-sizes.stage2-x86_64-apple-darwin --cfg rtopt -O -L x86_64-apple-darwin/rt
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/transmute-different-sizes.rs:18:17: 18:26 error: transmute called with differently sized types: i16 (16 bits) to i8 (8 bits) [E0512]
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/transmute-different-sizes.rs:18     let _: i8 = transmute(16i16);
                                                                                                                                     ^~~~~~~~~
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/transmute-different-sizes.rs:23:17: 23:26 error: transmute called with differently sized types: &T (could be 64 bits) to i8 (could be 8 bits) [E0512]
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/test/compile-fail/transmute-different-sizes.rs:23     let _: i8 = transmute(x);
                                                                                                                                     ^~~~~~~~~
error: aborting due to 2 previous errors

------------------------------------------

thread '[compile-fail] compile-fail/transmute-different-sizes.rs' panicked at 'explicit panic', /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-opt/build/src/compiletest/runtest.rs:1501


failures:
    [compile-fail] compile-fail/packed-struct-generic-transmute.rs
    [compile-fail] compile-fail/packed-struct-transmute.rs
    [compile-fail] compile-fail/transmute-different-sizes.rs

@GuillaumeGomez
Copy link
Member Author

@Manishearth: I'm still wondering what happened. I'm thinking about the error comment which could be invalid but it doesn't seem to...

@Manishearth
Copy link
Member

Those tests use error-pattern, which puts a pattern at the top of the file. You need to fix those patterns to match the new error message.

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 16, 2015

📌 Commit a3f9fc6 has been approved by Manishearth

bors added a commit that referenced this pull request Oct 16, 2015
@bors
Copy link
Contributor

bors commented Oct 16, 2015

⌛ Testing commit a3f9fc6 with merge beeaea4...

@bors bors merged commit a3f9fc6 into rust-lang:master Oct 16, 2015
@GuillaumeGomez GuillaumeGomez deleted the patch-5 branch October 16, 2015 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants