Skip to content

Add specific diagnostic when attempting to transmute between equal generic types #57044

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
Dec 31, 2018

Conversation

varkor
Copy link
Member

@varkor varkor commented Dec 21, 2018

Also clarifies the wording of E0512.

Fixes #49793.

@rust-highfive
Copy link
Contributor

r? @matthewjasper

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 21, 2018
@bors
Copy link
Collaborator

bors commented Dec 26, 2018

☔ The latest upstream changes (presumably #57108) made this pull request unmergeable. Please resolve the merge conflicts.

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 30, 2018

📌 Commit d178fce has been approved by matthewjasper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2018
@bors
Copy link
Collaborator

bors commented Dec 30, 2018

⌛ Testing commit d178fce with merge 94cca8cc0441e11dc3b8d290d95fec7e632d39fb...

@bors
Copy link
Collaborator

bors commented Dec 30, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 30, 2018
@rust-highfive

This comment has been minimized.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2018
@varkor
Copy link
Member Author

varkor commented Dec 30, 2018

@bors r=matthewjasper

@bors
Copy link
Collaborator

bors commented Dec 30, 2018

📌 Commit 3ed83e59e3ee00d08b473a49a5420d2889460308 has been approved by matthewjasper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 30, 2018
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0e06134c:start=1546163949861786982,finish=1546164007111771877,duration=57249984895
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[01:02:09] .................................................................................................... 4500/5211
[01:02:12] .................................................................................................... 4600/5211
[01:02:15] .................................................................................................... 4700/5211
[01:02:19] .................................................................................................... 4800/5211
[01:02:23] ......................................F............................................................. 4900/5211
[01:02:31] ..................................................i................................................. 5200/5211
obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/auxiliary" "-A" "unused"
[01:02:32] stdout:
[01:02:32] ------------------------------------------
[01:02:32] ------------------------------------------
[01:02:32] 
[01:02:32] ------------------------------------------
[01:02:32] stderr:
[01:02:32] ------------------------------------------
[01:02:32] {"message":"cannot transmute between types of different sizes, or dependently-sized types","code":{"code":"E0512","explanation":"\nTransmute with two differently sized types was attempted. Erroneous code\nexample:\n\n```compile_fail,E0512\nfn takes_u8(_: u8) {}\n\nfn main() {\n    unsafe { takes_u8(::std::mem::transmute(0u16)); }\n    // error: cannot transmute between types of different sizes,\n    //        or dependently-sized types\n}\n```\n\nPlease use types with same size or use the expected type directly. Example:\n\n```\nfn takes_u8(_: u8) {}\n\nfn main() {\n    unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!\n    // or:\n    unsafe { takes_u8(0u8); } // ok!\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/transmute/main.rs","byte_start":434,"byte_end":443,"line_start":16,"line_end":16,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    transmute(x) //~ ERROR cannot transmute between types of different sizes","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"source type: `<C as TypeConstructor<'a>>::T` (size can vary because of <C as TypeConstructor>::T)","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"target type: `<C as TypeConstructor<'b>>::T` (size can vary because of <C as TypeConstructor>::T)","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0512]: cannot transmute between types of different sizes, or dependently-sized types\n  --> /checkout/src/test/ui/transmute/main.rs:16:5\n   |\nLL |     transmute(x) //~ ERROR cannot transmute between types of different sizes\n   |     ^^^^^^^^^\n   |\n   = note: source type: `<C as TypeConstructor<'a>>::T` (size can vary because of <C as TypeConstructor>::T)\n   = note: target type: `<C as TypeConstructor<'b>>::T` (size can vary because of <C as TypeConstructor>::T)\n\n"}
[01:02:32] {"message":"cannot transmute between types of different sizes, or dependently-sized types","code":{"code":"E0512","explanation":"\nTransmute with two differently sized types was attempted. Erroneous code\nexample:\n\n```compile_fail,E0512\nfn takes_u8(_: u8) {}\n\nfn main() {\n    unsafe { takes_u8(::std::mem::transmute(0u16)); }\n    // error: cannot transmute between types of different sizes,\n    //        or dependently-sized types\n}\n```\n\nPlease use types with same size or use the expected type directly. Example:\n\n```\nfn takes_u8(_: u8) {}\n\nfn main() {\n    unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!\n    // or:\n    unsafe { takes_u8(0u8); } // ok!\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/transmute/main.rs","byte_start":546,"byte_end":555,"line_start":20,"line_end":20,"column_start":17,"column_end":26,"is_primary":true,"text":[{"text":"    let x: u8 = transmute(10u16); //~ ERROR cannot transmute between types of different  
[01:02:32] Build completed unsuccessfully in 0:03:58
[01:02:32] Build completed unsuccessfully in 0:03:58
[01:02:32] Makefile:48: recipe for target 'check' failed
[01:02:32] make: *** [check] Error 1
124968 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu
124964 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release
119264 ./obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps
115364 ./src/llvm/test/CodeGen

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Collaborator

bors commented Dec 30, 2018

⌛ Testing commit 3ed83e59e3ee00d08b473a49a5420d2889460308 with merge cd09c99c467e4e50d1cb5757ac35784b90dd370d...

@bors
Copy link
Collaborator

bors commented Dec 30, 2018

💔 Test failed - status-travis

@rust-highfive

This comment has been minimized.

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 30, 2018
@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2018
@varkor
Copy link
Member Author

varkor commented Dec 30, 2018

(Sorry, completely misread that previous error.)

@bors r=matthewjasper

@bors
Copy link
Collaborator

bors commented Dec 30, 2018

📌 Commit 7d5f6ce has been approved by matthewjasper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 30, 2018
@bors
Copy link
Collaborator

bors commented Dec 31, 2018

⌛ Testing commit 7d5f6ce with merge f39bd9b...

bors added a commit that referenced this pull request Dec 31, 2018
Add specific diagnostic when attempting to transmute between equal generic types

Also clarifies the wording of E0512.

Fixes #49793.
@bors
Copy link
Collaborator

bors commented Dec 31, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: matthewjasper
Pushing f39bd9b to master...

@bors bors merged commit 7d5f6ce into rust-lang:master Dec 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants