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

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

Merged
merged 3 commits into from Dec 31, 2018

Conversation

Projects
None yet
5 participants
@varkor
Copy link
Member

varkor commented Dec 21, 2018

Also clarifies the wording of E0512.

Fixes #49793.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 21, 2018

r? @matthewjasper

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

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 26, 2018

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

@varkor varkor force-pushed the varkor:E0512-equal-type branch from d1aae2b to d178fce Dec 28, 2018

@matthewjasper

This comment has been minimized.

Copy link
Contributor

matthewjasper commented Dec 30, 2018

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 30, 2018

📌 Commit d178fce has been approved by matthewjasper

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 30, 2018

⌛️ Testing commit d178fce with merge 94cca8c...

bors added a commit that referenced this pull request Dec 30, 2018

Auto merge of #57044 - varkor:E0512-equal-type, r=matthewjasper
Add specific diagnostic when attempting to transmute between equal generic types

Also clarifies the wording of E0512.

Fixes #49793.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 30, 2018

💔 Test failed - status-travis

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Dec 30, 2018

The job dist-i586-gnu-i586-i686-musl 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.
[00:52:07] 
[00:52:07] ---- [ui] ui/transmute/main.rs stdout ----
[00:52:07] diff of stderr:
[00:52:07] 
[00:52:07] 22 LL |     let x: u8 = transmute("test"); //~ ERROR cannot transmute between types of different sizes
[00:52:07] 24    |
[00:52:07] 24    |
[00:52:07] -    = note: source type: `&str` (128 bits)
[00:52:07] +    = note: source type: `&str` (64 bits)
[00:52:07] 26    = note: target type: `u8` (8 bits)
[00:52:07] 27 
[00:52:07] 28 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
[00:52:07] 
[00:52:07] The actual stderr differed from the expected stderr.
[00:52:07] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/main.stderr
[00:52:07] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/main.stderr
[00:52:07] To update references, rerun the tests and pass the `--bless` flag
[00:52:07] To only update this specific test, also pass `--test-args transmute/main.rs`
[00:52:07] error: 1 errors occurred comparing output.
[00:52:07] status: exit code: 1
[00:52:07] status: exit code: 1
[00:52:07] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/transmute/main.rs" "--target=i586-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/i586-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=cc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/auxiliary" "-A" "unused"
[00:52:07] ------------------------------------------
[00:52:07] 
[00:52:07] ------------------------------------------
[00:52:07] stderr:
[00:52:07] stderr:
[00:52:07] ------------------------------------------
[00:52:07] {"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"}
[00:52:07] {"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 sizes","highlight_start":17,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"source type: `u16` (16 bits)","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"target type: `u8` (8 bits)","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:20:17\n   |\nLL |     let x: u8 = transmute(10u16); //~ ERROR cannot transmute between types of different sizes\n   |                 ^^^^^^^^^\n   |\n   = note: source type: `u16` (16 bits)\n   = note: target type: `u8` (8 bits)\n\n"}
[00:52:07] {"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":662,"byte_end":671,"line_start":24,"line_end":24,"column_start":17,"column_end":26,"is_primary":true,"text":[{"text":"    let x: u8 = transmute(\"test\"); //~ ERROR cannot transmute between types of different sizes","highlight_start":17,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"source type: `&str` (64 bits)","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"target type: `u8` (8 bits)","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:24:17\n   |\nLL |     let x: u8 = transmute(\"test\"); //~ ERROR cannot transmute between types of different sizes\n   |                 ^^^^^^^^^\n   |\n   = note: source type: `&str` (64 bits)\n   = note: target type: `u8` (8 bits)\n\n"}
[00:52:07] {"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":800,"byte_end":809,"line_start":29,"line_end":29,"column_start":18,"column_end":27,"is_primary":true,"text":[{"text":"    let x: Foo = transmute(10); //~ ERROR cannot transmute between types of different sizes","highlight_start":18,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"source type: `i32` (32 bits)","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"target type: `Foo` (0 bits)","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:29:18\n   |\nLL |     let x: Foo = transmute(10); //~ ERROR cannot transmute between types of different sizes\n   |                  ^^^^^^^^^\n   |\n   = note: source type: `i32` (32 bits)\n   = note: target type: `Foo` (0 bits)\n\n"}
[00:52:07] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:52:07] {"message":"For more information about this error, try `rustc --explain E0512`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0512`.\n"}
[00:52:07] ------------------------------------------
[00:52:07] 
[00:52:07] thread '[ui] ui/transmute/main.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3245:9
[00:52:07] 
---
[00:52:07] 
[00:52:07] 
[00:52:07] 
[00:52:07] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:495:22
[00:52:07] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/i586-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-i586-unknown-linux-gnu" "--mode" "ui" "--target" "i586-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--linker" "cc" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/i586-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "8.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:52:07] 
[00:52:07] 
[00:52:07] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target i586-unknown-linux-gnu,i686-unknown-linux-musl
[00:52:07] Build completed unsuccessfully in 0:49:44
---
travis_time:end:0131190f:start=1546139507925159145,finish=1546139507935180849,duration=10021704
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0101f778
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1c9ea840
travis_time:start:1c9ea840
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:034c2b41
$ dmesg | grep -i kill

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)

@varkor

This comment has been minimized.

Copy link
Member

varkor commented Dec 30, 2018

@bors r=matthewjasper

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 30, 2018

📌 Commit 3ed83e5 has been approved by matthewjasper

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 30, 2018

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

This comment has been minimized.

Copy link
Contributor

bors commented Dec 30, 2018

⌛️ Testing commit 3ed83e5 with merge cd09c99...

bors added a commit that referenced this pull request Dec 30, 2018

Auto merge of #57044 - varkor:E0512-equal-type, r=matthewjasper
Add specific diagnostic when attempting to transmute between equal generic types

Also clarifies the wording of E0512.

Fixes #49793.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 30, 2018

💔 Test failed - status-travis

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Dec 30, 2018

The job dist-i586-gnu-i586-i686-musl 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.
[00:47:52] 
[00:47:52] ---- [ui] ui/transmute/main.rs stdout ----
[00:47:52] diff of stderr:
[00:47:52] 
[00:47:52] 22 LL |     let x: u8 = transmute("test"); //~ ERROR cannot transmute between types of different sizes
[00:47:52] 24    |
[00:47:52] 24    |
[00:47:52] -    = note: source type: `&str` ($STR bits)
[00:47:52] +    = note: source type: `&str` (64 bits)
[00:47:52] 26    = note: target type: `u8` (8 bits)
[00:47:52] 27 
[00:47:52] 28 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
[00:47:52] 
[00:47:52] The actual stderr differed from the expected stderr.
[00:47:52] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/main.stderr
[00:47:52] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/main.stderr
[00:47:52] To update references, rerun the tests and pass the `--bless` flag
[00:47:52] To only update this specific test, also pass `--test-args transmute/main.rs`
[00:47:52] error: 1 errors occurred comparing output.
[00:47:52] status: exit code: 1
[00:47:52] status: exit code: 1
[00:47:52] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/transmute/main.rs" "--target=i586-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/i586-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=cc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/transmute/main/auxiliary" "-A" "unused"
[00:47:52] ------------------------------------------
[00:47:52] 
[00:47:52] ------------------------------------------
[00:47:52] stderr:
[00:47:52] stderr:
[00:47:52] ------------------------------------------
[00:47:52] {"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"}
[00:47:52] {"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 sizes","highlight_start":17,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"source type: `u16` (16 bits)","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"target type: `u8` (8 bits)","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:20:17\n   |\nLL |     let x: u8 = transmute(10u16); //~ ERROR cannot transmute between types of different sizes\n   |                 ^^^^^^^^^\n   |\n   = note: source type: `u16` (16 bits)\n   = note: target type: `u8` (8 bits)\n\n"}
[00:47:52] {"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":662,"byte_end":671,"line_start":24,"line_end":24,"column_start":17,"column_end":26,"is_primary":true,"text":[{"text":"    let x: u8 = transmute(\"test\"); //~ ERROR cannot transmute between types of different sizes","highlight_start":17,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"source type: `&str` (64 bits)","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"target type: `u8` (8 bits)","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:24:17\n   |\nLL |     let x: u8 = transmute(\"test\"); //~ ERROR cannot transmute between types of different sizes\n   |                 ^^^^^^^^^\n   |\n   = note: source type: `&str` (64 bits)\n   = note: target type: `u8` (8 bits)\n\n"}
[00:47:52] {"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":800,"byte_end":809,"line_start":29,"line_end":29,"column_start":18,"column_end":27,"is_primary":true,"text":[{"text":"    let x: Foo = transmute(10); //~ ERROR cannot transmute between types of different sizes","highlight_start":18,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"source type: `i32` (32 bits)","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"target type: `Foo` (0 bits)","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:29:18\n   |\nLL |     let x: Foo = transmute(10); //~ ERROR cannot transmute between types of different sizes\n   |                  ^^^^^^^^^\n   |\n   = note: source type: `i32` (32 bits)\n   = note: target type: `Foo` (0 bits)\n\n"}
[00:47:52] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:47:52] {"message":"For more information about this error, try `rustc --explain E0512`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0512`.\n"}
[00:47:52] ------------------------------------------
[00:47:52] 
[00:47:52] thread '[ui] ui/transmute/main.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3245:9
[00:47:52] 
---
[00:47:52] 
[00:47:52] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:495:22
[00:47:52] 
[00:47:52] 
[00:47:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/i586-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-i586-unknown-linux-gnu" "--mode" "ui" "--target" "i586-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--linker" "cc" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/i586-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "8.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:47:52] 
[00:47:52] 
[00:47:52] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target i586-unknown-linux-gnu,i686-unknown-linux-musl
[00:47:52] Build completed unsuccessfully in 0:45:57
---
travis_time:end:05ed5fe0:start=1546176139455774512,finish=1546176139469469938,duration=13695426
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:009d4af5
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1041d7e0
travis_time:start:1041d7e0
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0a57d0ab
$ dmesg | grep -i kill

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)

@varkor varkor force-pushed the varkor:E0512-equal-type branch from 3ed83e5 to 7d5f6ce Dec 30, 2018

@varkor

This comment has been minimized.

Copy link
Member

varkor commented Dec 30, 2018

(Sorry, completely misread that previous error.)

@bors r=matthewjasper

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 30, 2018

📌 Commit 7d5f6ce has been approved by matthewjasper

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 31, 2018

⌛️ Testing commit 7d5f6ce with merge f39bd9b...

bors added a commit that referenced this pull request Dec 31, 2018

Auto merge of #57044 - varkor:E0512-equal-type, r=matthewjasper
Add specific diagnostic when attempting to transmute between equal generic types

Also clarifies the wording of E0512.

Fixes #49793.
@bors

This comment has been minimized.

Copy link
Contributor

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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment