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

Fix ICE with struct ctors and const generics. #60839

Merged
merged 1 commit into from
May 30, 2019

Conversation

davidtwco
Copy link
Member

@davidtwco davidtwco commented May 14, 2019

Fixes #60818.

r? @varkor

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 14, 2019
@varkor varkor added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 14, 2019
@rust-highfive
Copy link
Collaborator

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:224a7520:start=1557867525699836932,finish=1557867528231357459,duration=2531520527
$ 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
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[01:09:45] .................................................................................................... 300/5531
[01:09:48] .................................................................................................... 400/5531
[01:09:51] ..................................................................................................i. 500/5531
[01:09:55] .................................................................................................... 600/5531
[01:09:59] ....................................................................F............................... 700/5531
[01:10:09] ...............................................................................i...............i.... 900/5531
[01:10:13] .................................................................................................... 1000/5531
[01:10:16] ............iiiii................................................................................... 1100/5531
[01:10:19] .................................................................................................... 1200/5531
---
[01:13:01] failures:
[01:13:01] 
[01:13:01] ---- [ui] ui/const-generics/cannot-infer-type-for-const-param.rs stdout ----
[01:13:01] 
[01:13:01] error: Error: expected failure status (Some(1)) but received status Some(101).
[01:13:01] status: exit code: 101
[01:13:01] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/cannot-infer-type-for-const-param" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/cannot-infer-type-for-const-param/auxiliary" "-A" "unused"
[01:13:01] ------------------------------------------
[01:13:01] 
[01:13:01] ------------------------------------------
[01:13:01] stderr:
[01:13:01] stderr:
[01:13:01] ------------------------------------------
[01:13:01] warning: the feature `const_generics` is incomplete and may cause the compiler to crash
[01:13:01]   --> /checkout/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs:1:12
[01:13:01]    |
[01:13:01] LL | #![feature(const_generics)]
[01:13:01]    |            ^^^^^^^^^^^^^^
[01:13:01] 
[01:13:01] error: internal compiler error: broken MIR in DefId(0:17 ~ cannot_infer_type_for_const_param[317d]::main[0]) (_1 = Foo::<_>(move _2,)): bad assignment (Foo<Const { ty: usize, val: Scalar(Bits { size: 8, bits: 3 }) }> = Foo<_>): NoSolution
[01:13:01]    |
[01:13:01]    |
[01:13:01] LL |     let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed
[01:13:01] 
[01:13:01] 
[01:13:01] error: internal compiler error: broken MIR in DefId(0:17 ~ cannot_infer_type_for_const_param[317d]::main[0]) (_1 = Foo::<_>(move _2,)): bad user type on rvalue (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:12 ~ cannot_infer_type_for_const_param[317d]::Foo[0]), UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:18 ~ cannot_infer_type_for_const_param[317d]::main[0]::{{constant}}[0]), []) }], user_self_ty: None }) }, span: /checkout/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs:10:13: 10:32, inferred_ty: Foo<Const { ty: usize, val: Scalar(Bits { size: 8, bits: 3 }) }> } = Foo<_>): NoSolution
[01:13:01]    |
[01:13:01]    |
[01:13:01] LL |     let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed
[01:13:01] 
[01:13:01] 
[01:13:01] thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:356:17
[01:13:01] 
[01:13:01] error: internal compiler error: unexpected panic
[01:13:01] 
[01:13:01] note: the compiler unexpectedly panicked. this is a bug.
[01:13:01] note: the compiler unexpectedly panicked. this is a bug.
[01:13:01] 
[01:13:01] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[01:13:01] 
[01:13:01] note: rustc 1.36.0-dev running on x86_64-unknown-linux-gnu
[01:13:01] 
[01:13:01] note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath
[01:13:01] 
[01:13:01] ------------------------------------------
[01:13:01] 
[01:13:01] 
---
[01:13:01] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:512:22
[01:13:01] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:13:01] 
[01:13:01] 
[01:13:01] 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/x86_64-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-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--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/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:13:01] 
[01:13:01] 
[01:13:01] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:13:01] Build completed unsuccessfully in 0:04:42
[01:13:01] Build completed unsuccessfully in 0:04:42
[01:13:01] make: *** [check] Error 1
[01:13:01] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0725b959
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue May 14 22:12:00 UTC 2019

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)

@davidtwco davidtwco force-pushed the const-generics-struct-ctor branch from 6e04be0 to b21b9c3 Compare May 15, 2019 15:24
@davidtwco
Copy link
Member Author

I've force-pushed some changes, resolving the review feedback. This will still fail CI on the expected test.

@rust-highfive
Copy link
Collaborator

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:056b9108:start=1557934737036908728,finish=1557934965199017823,duration=228162109095
$ 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
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[01:10:00] .................................................................................................... 300/5533
[01:10:03] .................................................................................................... 400/5533
[01:10:06] ..................................................................................................i. 500/5533
[01:10:10] .................................................................................................... 600/5533
[01:10:13] ....................................................................F............................... 700/5533
[01:10:23] ...............................................................................i...............i.... 900/5533
[01:10:27] .................................................................................................... 1000/5533
[01:10:31] ............iiiii................................................................................... 1100/5533
[01:10:33] .................................................................................................... 1200/5533
---
[01:13:10] failures:
[01:13:10] 
[01:13:10] ---- [ui] ui/const-generics/cannot-infer-type-for-const-param.rs stdout ----
[01:13:10] 
[01:13:10] error: Error: expected failure status (Some(1)) but received status Some(101).
[01:13:10] status: exit code: 101
[01:13:10] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/cannot-infer-type-for-const-param" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/cannot-infer-type-for-const-param/auxiliary" "-A" "unused"
[01:13:10] ------------------------------------------
[01:13:10] 
[01:13:10] ------------------------------------------
[01:13:10] stderr:
[01:13:10] stderr:
[01:13:10] ------------------------------------------
[01:13:10] warning: the feature `const_generics` is incomplete and may cause the compiler to crash
[01:13:10]   --> /checkout/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs:1:12
[01:13:10]    |
[01:13:10] LL | #![feature(const_generics)]
[01:13:10]    |            ^^^^^^^^^^^^^^
[01:13:10] 
[01:13:10] error: internal compiler error: broken MIR in DefId(0:17 ~ cannot_infer_type_for_const_param[317d]::main[0]) (_1 = Foo::<_>(move _2,)): bad assignment (Foo<Const { ty: usize, val: Scalar(Bits { size: 8, bits: 3 }) }> = Foo<_>): NoSolution
[01:13:10]    |
[01:13:10]    |
[01:13:10] LL |     let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed
[01:13:10] 
[01:13:10] 
[01:13:10] error: internal compiler error: broken MIR in DefId(0:17 ~ cannot_infer_type_for_const_param[317d]::main[0]) (_1 = Foo::<_>(move _2,)): bad user type on rvalue (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:12 ~ cannot_infer_type_for_const_param[317d]::Foo[0]), UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:18 ~ cannot_infer_type_for_const_param[317d]::main[0]::{{constant}}[0]), []) }], user_self_ty: None }) }, span: /checkout/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs:10:13: 10:32, inferred_ty: Foo<Const { ty: usize, val: Scalar(Bits { size: 8, bits: 3 }) }> } = Foo<_>): NoSolution
[01:13:10]    |
[01:13:10]    |
[01:13:10] LL |     let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed
[01:13:10] 
[01:13:10] 
[01:13:10] thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:356:17
[01:13:10] 
[01:13:10] error: internal compiler error: unexpected panic
[01:13:10] 
[01:13:10] note: the compiler unexpectedly panicked. this is a bug.
[01:13:10] note: the compiler unexpectedly panicked. this is a bug.
[01:13:10] 
[01:13:10] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[01:13:10] 
[01:13:10] note: rustc 1.36.0-dev running on x86_64-unknown-linux-gnu
[01:13:10] 
[01:13:10] note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath
[01:13:10] 
[01:13:10] ------------------------------------------
[01:13:10] 
[01:13:10] 
---
[01:13:10] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:512:22
[01:13:10] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:13:10] 
[01:13:10] 
[01:13:10] 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/x86_64-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-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--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/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:13:10] 
[01:13:10] 
[01:13:10] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:13:10] Build completed unsuccessfully in 0:04:34
[01:13:10] Build completed unsuccessfully in 0:04:34
[01:13:10] Makefile:48: recipe for target 'check' failed
[01:13:10] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:11b1b590
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed May 15 16:56:05 UTC 2019
---
travis_time:end:2b664880:start=1557939366503180852,finish=1557939366509792881,duration=6612029
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:09156f58
$ 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:038d0350
$ 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)

@yodaldevoid
Copy link
Contributor

With #60742 merged, this should no longer be blocked.

This commit fixes a ICE where struct constructors were resulting in an
ICE with const generics. Previously, a `match` in `type_of` did not have
an arm for the `DefKind::Ctor` resolutions and therefore would assume
that the type did not have generics.
@davidtwco davidtwco force-pushed the const-generics-struct-ctor branch from b21b9c3 to 41aaf7b Compare May 29, 2019 07:30
@davidtwco
Copy link
Member Author

davidtwco commented May 29, 2019

I've pushed a version rebased atop #60742 which was merged, this should now pass CI.

@varkor
Copy link
Member

varkor commented May 29, 2019

r=me once Travis passes.

@yodaldevoid
Copy link
Contributor

Travis passed, this should be ready to roll.

@varkor
Copy link
Member

varkor commented May 29, 2019

@bors r+

@bors
Copy link
Contributor

bors commented May 29, 2019

📌 Commit 41aaf7b has been approved by varkor

@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-blocked Status: Blocked on something else such as an RFC or other implementation work. labels May 29, 2019
Centril added a commit to Centril/rust that referenced this pull request May 30, 2019
…r, r=varkor

Fix ICE with struct ctors and const generics.

Fixes rust-lang#60818.

r? @varkor
Centril added a commit to Centril/rust that referenced this pull request May 30, 2019
…r, r=varkor

Fix ICE with struct ctors and const generics.

Fixes rust-lang#60818.

r? @varkor
bors added a commit that referenced this pull request May 30, 2019
Rollup of 11 pull requests

Successful merges:

 - #60802 (upgrade rustdoc's `pulldown-cmark` to 0.5.2)
 - #60839 (Fix ICE with struct ctors and const generics.)
 - #60850 (Stabilize RefCell::try_borrow_unguarded)
 - #61231 (Fix linkage diagnostic so it doesn't ICE for external crates)
 - #61244 (Box::into_vec: use Box::into_raw instead of mem::forget)
 - #61279 (implicit `Option`-returning doctests)
 - #61280 (Revert "Disable solaris target since toolchain no longer builds")
 - #61284 (Update all s3 URLs used on CI with subdomains)
 - #61321 (libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'.)
 - #61322 (ci: display more debug information in the init_repo script)
 - #61333 (Fix ICE with APIT in a function with a const parameter)

Failed merges:

 - #61304 (Speed up Azure CI installing Windows dependencies)

r? @ghost
bors added a commit that referenced this pull request May 30, 2019
Rollup of 11 pull requests

Successful merges:

 - #60802 (upgrade rustdoc's `pulldown-cmark` to 0.5.2)
 - #60839 (Fix ICE with struct ctors and const generics.)
 - #60850 (Stabilize RefCell::try_borrow_unguarded)
 - #61231 (Fix linkage diagnostic so it doesn't ICE for external crates)
 - #61244 (Box::into_vec: use Box::into_raw instead of mem::forget)
 - #61279 (implicit `Option`-returning doctests)
 - #61280 (Revert "Disable solaris target since toolchain no longer builds")
 - #61284 (Update all s3 URLs used on CI with subdomains)
 - #61321 (libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'.)
 - #61322 (ci: display more debug information in the init_repo script)
 - #61333 (Fix ICE with APIT in a function with a const parameter)

Failed merges:

 - #61304 (Speed up Azure CI installing Windows dependencies)

r? @ghost
@bors bors merged commit 41aaf7b into rust-lang:master May 30, 2019
@davidtwco davidtwco deleted the const-generics-struct-ctor branch May 31, 2019 07:58
@varkor varkor added the F-const_generics `#![feature(const_generics)]` label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-const_generics `#![feature(const_generics)]` 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.

ICE when using struct constructor with explicit const generic arguments
5 participants