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

WF-check all ty::Const's, not just array lengths. #70107

Merged
merged 4 commits into from
Jun 3, 2020

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Mar 18, 2020

fixes #68977

This PR removes the special case for array length in wf::compute and
checks the well formedness of all consts.

Changes PredicateKind::WellFormed to take a GenericArg and updates wf::obligations.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 18, 2020
@rust-highfive
Copy link
Collaborator

r? @varkor

(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 Mar 18, 2020
@varkor varkor added the F-const_generics `#![feature(const_generics)]` label Mar 18, 2020
src/librustc/traits/mod.rs Outdated Show resolved Hide resolved
@varkor
Copy link
Member

varkor commented Mar 18, 2020

Does #68977 (comment) compile after this change?

@lcnr
Copy link
Contributor Author

lcnr commented Mar 18, 2020

It does not, it has the following errors:

warning: the feature `const_generics` is incomplete and may cause the compiler to crash
  --> $DIR/issue-68977.rs:1:12
   |
LL | #![feature(const_generics)]
   |            ^^^^^^^^^^^^^^
   |
   = note: `#[warn(incomplete_features)]` on by default

error: constant expression depends on a generic parameter
  --> $DIR/issue-68977.rs:31:44
   |
LL |     FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage,
   |                                            ^^^^^^^^^^
   |
   = note: this may fail depending on what value the parameter takes

error: aborting due to previous error

@varkor
Copy link
Member

varkor commented Mar 18, 2020

@lcnr: could you add that as a failing test case? It is not supposed to compile, but currently does.

@eddyb: presumably this is going to require a crater run, as this issue has been extant for some time.

@eddyb
Copy link
Member

eddyb commented Mar 18, 2020

@eddyb: presumably this is going to require a crater run, as this issue has been extant for some time.

You mean among const generics users? Nothing changes without #![feature(const_generics)].

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2020-03-18T16:27:56.0661268Z ========================== Starting Command Output ===========================
2020-03-18T16:27:56.0663735Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/f12306ff-8661-454c-b26a-3eff9e36ea37.sh
2020-03-18T16:27:56.0664033Z 
2020-03-18T16:27:56.0669579Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-18T16:27:56.0695618Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70107/merge to s
2020-03-18T16:27:56.0705993Z Task         : Get sources
2020-03-18T16:27:56.0706348Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-18T16:27:56.0706689Z Version      : 1.0.0
2020-03-18T16:27:56.0706935Z Author       : Microsoft
---
2020-03-18T16:27:57.0757658Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-18T16:27:57.0777161Z ##[command]git config gc.auto 0
2020-03-18T16:27:57.0782213Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-18T16:27:57.0786989Z ##[command]git config --get-all http.proxy
2020-03-18T16:27:57.0795564Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70107/merge:refs/remotes/pull/70107/merge
---
2020-03-18T17:20:46.3982885Z .................................................................................................... 1700/9796
2020-03-18T17:20:50.3164056Z .................................................................................................... 1800/9796
2020-03-18T17:21:00.4782764Z ..........................................................................i......................... 1900/9796
2020-03-18T17:21:06.1971250Z .................................................................................................... 2000/9796
2020-03-18T17:21:13.3545301Z ................................................................iiiii............................... 2100/9796
2020-03-18T17:21:29.6626176Z .................................................................................................... 2300/9796
2020-03-18T17:21:31.7964322Z .................................................................................................... 2400/9796
2020-03-18T17:21:34.6095833Z .................................................................................................... 2500/9796
2020-03-18T17:21:53.8345600Z .................................................................................................... 2600/9796
---
2020-03-18T17:24:27.9588710Z ....................................i...............i............................................... 5000/9796
2020-03-18T17:24:36.3969812Z .................................................................................................... 5100/9796
2020-03-18T17:24:42.4235688Z ...............................................................................i.................... 5200/9796
2020-03-18T17:24:47.5822600Z .................................................................................................... 5300/9796
2020-03-18T17:24:56.9935490Z ............................................................ii.ii........i...i...................... 5400/9796
2020-03-18T17:25:00.9674488Z ...................................................................................................i 5500/9796
2020-03-18T17:25:13.5326477Z .................................................................................................... 5700/9796
2020-03-18T17:25:19.3310627Z .....................................................i.............................................. 5800/9796
2020-03-18T17:25:25.4961658Z .................................................................................................... 5900/9796
2020-03-18T17:25:34.4424275Z .................................................................................................... 6000/9796
2020-03-18T17:25:34.4424275Z .................................................................................................... 6000/9796
2020-03-18T17:25:40.5604580Z ...............................................ii...i..i.i..........i............................... 6100/9796
2020-03-18T17:25:59.6279437Z .................................................................................................... 6300/9796
2020-03-18T17:26:05.6689144Z .................................................................................................... 6400/9796
2020-03-18T17:26:09.8178788Z ..............................................................................i.ii.................. 6500/9796
2020-03-18T17:26:21.9469211Z .................................................................................................... 6600/9796
---
2020-03-18T17:28:20.3119944Z .................................................................................................... 7800/9796
2020-03-18T17:28:25.3967069Z .................................................................................................... 7900/9796
2020-03-18T17:28:31.0851899Z .............................................................i...................................... 8000/9796
2020-03-18T17:28:40.4269007Z .................................................................................................... 8100/9796
2020-03-18T17:28:45.7577777Z ..........iiiiiiiiii.i.............................................................................. 8200/9796
2020-03-18T17:28:58.5970319Z .................................................................................................... 8400/9796
2020-03-18T17:29:05.9851036Z .................................................................................................... 8500/9796
2020-03-18T17:29:18.5824016Z .................................................................................................... 8600/9796
2020-03-18T17:29:24.6186159Z .................................................................................................... 8700/9796
---
2020-03-18T17:31:08.3173922Z ---- [ui] ui/const-generics/issues/issue-61747.rs stdout ----
2020-03-18T17:31:08.3177566Z 
2020-03-18T17:31:08.3178440Z error: test compilation failed although it shouldn't!
2020-03-18T17:31:08.3178742Z status: exit code: 1
2020-03-18T17:31:08.3180856Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/issues/issue-61747.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-61747" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-A" "unused" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-61747/auxiliary"
2020-03-18T17:31:08.3182576Z ------------------------------------------
2020-03-18T17:31:08.3182757Z 
2020-03-18T17:31:08.3183141Z ------------------------------------------
2020-03-18T17:31:08.3183352Z stderr:
---
2020-03-18T17:31:08.3186283Z 
2020-03-18T17:31:08.3186507Z error: constant expression depends on a generic parameter
2020-03-18T17:31:08.3187081Z   --> /checkout/src/test/ui/const-generics/issues/issue-61747.rs:9:23
2020-03-18T17:31:08.3187357Z    |
2020-03-18T17:31:08.3187734Z LL |     fn successor() -> Const<{C + 1}> {
2020-03-18T17:31:08.3188227Z    |
2020-03-18T17:31:08.3188482Z    = note: this may fail depending on what value the parameter takes
2020-03-18T17:31:08.3188700Z 
2020-03-18T17:31:08.3188896Z error: aborting due to previous error
---
2020-03-18T17:31:08.3190240Z ---- [ui] ui/const-generics/issues/issue-66205.rs stdout ----
2020-03-18T17:31:08.3190461Z 
2020-03-18T17:31:08.3190857Z error: test compilation failed although it shouldn't!
2020-03-18T17:31:08.3191143Z status: exit code: 101
2020-03-18T17:31:08.3193218Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/issues/issue-66205.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-66205" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-A" "unused" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-66205/auxiliary"
2020-03-18T17:31:08.3195805Z ------------------------------------------
2020-03-18T17:31:08.3195994Z 
2020-03-18T17:31:08.3197984Z ------------------------------------------
2020-03-18T17:31:08.3198615Z stderr:
2020-03-18T17:31:08.3198615Z stderr:
2020-03-18T17:31:08.3199047Z ------------------------------------------
2020-03-18T17:31:08.3203927Z error: internal compiler error: broken MIR in DefId(0:3 ~ issue_66205[317d]::fact[0]) (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_66205[317d]::fact[0]), UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:5 ~ issue_66205[317d]::fact[0]::{{constant}}[0]), [Const { ty: usize, val: Param(N/#0) }], None) }], user_self_ty: None }) }, span: /checkout/src/test/ui/const-generics/issues/issue-66205.rs:7:5: 7:22, inferred_ty: fn() {fact::<{ N - 1 }>} }): bad user type AscribeUserType(fn() {fact::<{ N - 1 }>}, DefId(0:3 ~ issue_66205[317d]::fact[0]) UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:5 ~ issue_66205[317d]::fact[0]::{{constant}}[0]), [Const { ty: usize, val: Param(N/#0) }], None) }], user_self_ty: None }): NoSolution
2020-03-18T17:31:08.3206294Z 
2020-03-18T17:31:08.3206978Z thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:360:17
2020-03-18T17:31:08.3207736Z 
2020-03-18T17:31:08.3207959Z error: internal compiler error: unexpected panic
2020-03-18T17:31:08.3208161Z 
2020-03-18T17:31:08.3208401Z note: the compiler unexpectedly panicked. this is a bug.
2020-03-18T17:31:08.3208401Z note: the compiler unexpectedly panicked. this is a bug.
2020-03-18T17:31:08.3208607Z 
2020-03-18T17:31:08.3209317Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2020-03-18T17:31:08.3209590Z 
2020-03-18T17:31:08.3210107Z note: rustc 1.44.0-nightly (4c2e80e8c 2020-03-18) running on x86_64-unknown-linux-gnu
2020-03-18T17:31:08.3210369Z 
2020-03-18T17:31:08.3211015Z note: compiler flags: -Z threads=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
2020-03-18T17:31:08.3211630Z 
2020-03-18T17:31:08.3212074Z ------------------------------------------
2020-03-18T17:31:08.3212712Z 
2020-03-18T17:31:08.3212812Z 
---
2020-03-18T17:31:08.3221272Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22
2020-03-18T17:31:08.3225502Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2020-03-18T17:31:08.3230144Z 
2020-03-18T17:31:08.3230495Z 
2020-03-18T17:31:08.3235551Z 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-7/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -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" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2020-03-18T17:31:08.3238654Z 
2020-03-18T17:31:08.3238879Z 
2020-03-18T17:31:08.3244466Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-03-18T17:31:08.3244898Z Build completed unsuccessfully in 0:59:11
2020-03-18T17:31:08.3244898Z Build completed unsuccessfully in 0:59:11
2020-03-18T17:31:08.3288708Z == clock drift check ==
2020-03-18T17:31:08.3314242Z   local time: Wed Mar 18 17:31:08 UTC 2020
2020-03-18T17:31:08.7591155Z   network time: Wed, 18 Mar 2020 17:31:08 GMT
2020-03-18T17:31:08.7594414Z == end clock drift check ==
2020-03-18T17:31:09.2436726Z 
2020-03-18T17:31:09.2507713Z ##[error]Bash exited with code '1'.
2020-03-18T17:31:09.2525120Z ##[section]Finishing: Run build
2020-03-18T17:31:09.2575839Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70107/merge to s
2020-03-18T17:31:09.2581272Z Task         : Get sources
2020-03-18T17:31:09.2581630Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-18T17:31:09.2581956Z Version      : 1.0.0
2020-03-18T17:31:09.2582207Z Author       : Microsoft
2020-03-18T17:31:09.2582207Z Author       : Microsoft
2020-03-18T17:31:09.2582575Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-03-18T17:31:09.2582993Z ==============================================================================
2020-03-18T17:31:09.5788930Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-03-18T17:31:09.5836724Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70107/merge to s
2020-03-18T17:31:09.5943967Z Cleaning up task key
2020-03-18T17:31:09.5945263Z Start cleaning up orphan processes.
2020-03-18T17:31:09.6233980Z Terminate orphan process: pid (3873) (python)
2020-03-18T17:31:09.6276958Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@varkor
Copy link
Member

varkor commented Mar 18, 2020

You mean among const generics users? Nothing changes without #![feature(const_generics)].

Ah, I was wondering whether this also had implications for consts in arrays. That's fine, then.

@eddyb
Copy link
Member

eddyb commented Mar 18, 2020

Ah, I was wondering whether this also had implications for consts in arrays.

No, those (array lengths) were the only consts being checked, so nothing changes for them.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2020-03-18T17:42:01.0656115Z ========================== Starting Command Output ===========================
2020-03-18T17:42:01.0660934Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/0b333c1e-53fb-4908-b9f6-20ccb482a321.sh
2020-03-18T17:42:01.0661493Z 
2020-03-18T17:42:01.0666179Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-18T17:42:01.0687034Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70107/merge to s
2020-03-18T17:42:01.0690740Z Task         : Get sources
2020-03-18T17:42:01.0691027Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-18T17:42:01.0691368Z Version      : 1.0.0
2020-03-18T17:42:01.0691559Z Author       : Microsoft
---
2020-03-18T17:42:02.0610339Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-18T17:42:02.0615671Z ##[command]git config gc.auto 0
2020-03-18T17:42:02.0619860Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-18T17:42:02.0623645Z ##[command]git config --get-all http.proxy
2020-03-18T17:42:02.0630097Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70107/merge:refs/remotes/pull/70107/merge
---
2020-03-18T18:44:18.5227449Z .................................................................................................... 1700/9797
2020-03-18T18:44:22.9673621Z .................................................................................................... 1800/9797
2020-03-18T18:44:34.7817488Z ...........................................................................i........................ 1900/9797
2020-03-18T18:44:41.7062279Z .................................................................................................... 2000/9797
2020-03-18T18:44:50.0736917Z .................................................................iiiii.............................. 2100/9797
2020-03-18T18:45:09.0647163Z .................................................................................................... 2300/9797
2020-03-18T18:45:11.3830890Z .................................................................................................... 2400/9797
2020-03-18T18:45:14.5174727Z .................................................................................................... 2500/9797
2020-03-18T18:45:35.9399935Z .................................................................................................... 2600/9797
---
2020-03-18T18:48:24.7282489Z .....................................i...............i.............................................. 5000/9797
2020-03-18T18:48:34.2291789Z .................................................................................................... 5100/9797
2020-03-18T18:48:40.9886610Z ................................................................................i................... 5200/9797
2020-03-18T18:48:46.7006929Z .................................................................................................... 5300/9797
2020-03-18T18:48:57.6228694Z .............................................................ii.ii........i...i..................... 5400/9797
2020-03-18T18:49:06.3218120Z i................................................................................................... 5600/9797
2020-03-18T18:49:16.9928064Z .................................................................................................... 5700/9797
2020-03-18T18:49:23.7676625Z ......................................................i............................................. 5800/9797
2020-03-18T18:49:30.5381415Z .................................................................................................... 5900/9797
2020-03-18T18:49:30.5381415Z .................................................................................................... 5900/9797
2020-03-18T18:49:40.2351169Z .................................................................................................... 6000/9797
2020-03-18T18:49:47.2297264Z ................................................ii...i..ii...........i.............................. 6100/9797
2020-03-18T18:50:08.6500548Z .................................................................................................... 6300/9797
2020-03-18T18:50:16.3570111Z .................................................................................................... 6400/9797
2020-03-18T18:50:16.3570111Z .................................................................................................... 6400/9797
2020-03-18T18:50:24.9560263Z ..............................................................................i..ii................. 6500/9797
2020-03-18T18:50:48.8328037Z .................................................................................................... 6700/9797
2020-03-18T18:50:58.4679947Z ............................................................................i....................... 6800/9797
2020-03-18T18:51:00.6303673Z .................................................................................................... 6900/9797
2020-03-18T18:51:02.9144857Z .................................................................................................... 7000/9797
---
2020-03-18T18:52:55.0329245Z .................................................................................................... 7800/9797
2020-03-18T18:53:00.7255518Z .................................................................................................... 7900/9797
2020-03-18T18:53:07.2387768Z ..............................................................i..................................... 8000/9797
2020-03-18T18:53:17.8030479Z .................................................................................................... 8100/9797
2020-03-18T18:53:24.3624602Z ...........iiiiiiiiii.i............................................................................. 8200/9797
2020-03-18T18:53:38.1829922Z .................................................................................................... 8400/9797
2020-03-18T18:53:46.5087684Z .................................................................................................... 8500/9797
2020-03-18T18:54:01.3696520Z .................................................................................................... 8600/9797
2020-03-18T18:54:07.7972493Z .................................................................................................... 8700/9797
---
2020-03-18T18:56:08.9049213Z ---- [ui] ui/const-generics/issues/issue-66205.rs stdout ----
2020-03-18T18:56:08.9049422Z 
2020-03-18T18:56:08.9049825Z error: test compilation failed although it shouldn't!
2020-03-18T18:56:08.9050100Z status: exit code: 101
2020-03-18T18:56:08.9052058Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/issues/issue-66205.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-66205" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-A" "unused" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-66205/auxiliary"
2020-03-18T18:56:08.9053665Z ------------------------------------------
2020-03-18T18:56:08.9053835Z 
2020-03-18T18:56:08.9054201Z ------------------------------------------
2020-03-18T18:56:08.9054397Z stderr:
2020-03-18T18:56:08.9054397Z stderr:
2020-03-18T18:56:08.9054749Z ------------------------------------------
2020-03-18T18:56:08.9061079Z error: internal compiler error: broken MIR in DefId(0:3 ~ issue_66205[317d]::fact[0]) (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_66205[317d]::fact[0]), UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:5 ~ issue_66205[317d]::fact[0]::{{constant}}[0]), [Const { ty: usize, val: Param(N/#0) }], None) }], user_self_ty: None }) }, span: /checkout/src/test/ui/const-generics/issues/issue-66205.rs:7:5: 7:22, inferred_ty: fn() {fact::<{ N - 1 }>} }): bad user type AscribeUserType(fn() {fact::<{ N - 1 }>}, DefId(0:3 ~ issue_66205[317d]::fact[0]) UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:5 ~ issue_66205[317d]::fact[0]::{{constant}}[0]), [Const { ty: usize, val: Param(N/#0) }], None) }], user_self_ty: None }): NoSolution
2020-03-18T18:56:08.9068326Z 
2020-03-18T18:56:08.9069065Z thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:360:17
2020-03-18T18:56:08.9069779Z 
2020-03-18T18:56:08.9069983Z error: internal compiler error: unexpected panic
2020-03-18T18:56:08.9070171Z 
2020-03-18T18:56:08.9070388Z note: the compiler unexpectedly panicked. this is a bug.
2020-03-18T18:56:08.9070388Z note: the compiler unexpectedly panicked. this is a bug.
2020-03-18T18:56:08.9070597Z 
2020-03-18T18:56:08.9071273Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2020-03-18T18:56:08.9072038Z note: rustc 1.44.0-nightly (44f5de6f8 2020-03-18) running on x86_64-unknown-linux-gnu
2020-03-18T18:56:08.9072425Z 
2020-03-18T18:56:08.9072425Z 
2020-03-18T18:56:08.9078819Z note: compiler flags: -Z threads=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0
2020-03-18T18:56:08.9079384Z 
2020-03-18T18:56:08.9080053Z ------------------------------------------
2020-03-18T18:56:08.9080223Z 
2020-03-18T18:56:08.9080315Z 
---
2020-03-18T18:56:08.9082605Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22
2020-03-18T18:56:08.9083027Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2020-03-18T18:56:08.9083251Z 
2020-03-18T18:56:08.9083353Z 
2020-03-18T18:56:08.9087724Z 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-7/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -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" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2020-03-18T18:56:08.9090693Z 
2020-03-18T18:56:08.9090789Z 
2020-03-18T18:56:08.9091350Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-03-18T18:56:08.9091709Z Build completed unsuccessfully in 1:10:01
2020-03-18T18:56:08.9091709Z Build completed unsuccessfully in 1:10:01
2020-03-18T18:56:08.9136544Z == clock drift check ==
2020-03-18T18:56:08.9155473Z   local time: Wed Mar 18 18:56:08 UTC 2020
2020-03-18T18:56:09.2139784Z   network time: Wed, 18 Mar 2020 18:56:09 GMT
2020-03-18T18:56:09.2142468Z == end clock drift check ==
2020-03-18T18:56:09.6868535Z 
2020-03-18T18:56:09.6953530Z ##[error]Bash exited with code '1'.
2020-03-18T18:56:09.6971617Z ##[section]Finishing: Run build
2020-03-18T18:56:09.7028831Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70107/merge to s
2020-03-18T18:56:09.7034115Z Task         : Get sources
2020-03-18T18:56:09.7034470Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-18T18:56:09.7034812Z Version      : 1.0.0
2020-03-18T18:56:09.7035036Z Author       : Microsoft
2020-03-18T18:56:09.7035036Z Author       : Microsoft
2020-03-18T18:56:09.7035402Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-03-18T18:56:09.7035837Z ==============================================================================
2020-03-18T18:56:10.0625852Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-03-18T18:56:10.0671963Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70107/merge to s
2020-03-18T18:56:10.0772750Z Cleaning up task key
2020-03-18T18:56:10.0774160Z Start cleaning up orphan processes.
2020-03-18T18:56:10.1121783Z Terminate orphan process: pid (3577) (python)
2020-03-18T18:56:10.1177270Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@lcnr
Copy link
Contributor Author

lcnr commented Mar 18, 2020

don't know how to even start fixing the last failing test 🤷‍♂️

@eddyb
Copy link
Member

eddyb commented Mar 18, 2020

It should be producing a type-checking error but it doesn't.
Maybe try replacing func::<{N - 1}>(); with MyStruct::<{N - 1}>;?
Neither should pass WF checks, something is not right here.

@lcnr
Copy link
Contributor Author

lcnr commented Mar 18, 2020

struct MyStruct<const N: usize>;

fn fact<const N: usize>() {
    MyStruct::<{ N - 1 }>;
}

fn main() {}

also fails with

error: internal compiler error: broken MIR in DefId(0:6 ~ issue_66205_struct_dup[317d]::fact[0]) (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:4 ~ issue_66205_struct_dup[317d]::MyStruct[0]::{{constructor}}[0]), UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:8 ~ issue_66205_struct_dup[317d]::fact[0]::{{constant}}[0]), [Const { ty: usize, val: Param(N/#0) }], None) }], user_self_ty: None }) }, span: /home/programming/rust/src/test/ui/const-generics/issues/issue-66205-struct-dup.rs:9:5: 9:26, inferred_ty: MyStruct<{ N - 1 }> }): bad user type AscribeUserType(MyStruct<{ N - 1 }>, DefId(0:4 ~ issue_66205_struct_dup[317d]::MyStruct[0]::{{constructor}}[0]) UserSubsts { substs: [Const { ty: usize, val: Unevaluated(DefId(0:8 ~ issue_66205_struct_dup[317d]::fact[0]::{{constant}}[0]), [Const { ty: usize, val: Param(N/#0) }], None) }], user_self_ty: None }): NoSolution

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:360:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

@eddyb
Copy link
Member

eddyb commented Mar 18, 2020

What about this?

struct MyStruct<const N: usize>;

fn fact<const N: usize>() {
    let x: MyStruct<{ N - 1 }> = MyStruct;
}

fn main() {}

If this doesn't trigger WF checks, I don't know what does 😕.

@lcnr
Copy link
Contributor Author

lcnr commented Mar 18, 2020

@eddyb this works, probably has something to do with the turbofish?

i.e. that we don't check WF of const exprs as a param of an expr, ?? which we dont test for WF, but later do in mir where it fails ????

@lcnr

This comment has been minimized.

@eddyb
Copy link
Member

eddyb commented Mar 19, 2020

I left a comment with the problems with WF here: #68977 (comment).
This might be a bit tricky to do without Ty::walk handling ty::Consts (which I'm working on solving, see #70164), but potentially still doable.

@lcnr
Copy link
Contributor Author

lcnr commented Mar 19, 2020

Open questions (will be edited while I make progress implementing this)

  • should Predicate::WellFormedConst use an owned const instead of an interned one? (Const is copy)
  • I use compute_const both in FulfillProcessor::process_obligation and wf::predicate_obligations. Is this required?

@eddyb
Copy link
Member

eddyb commented Mar 19, 2020

should Predicate::WellFormedConst use an owned const instead of an interned one? (Const is copy)

Always use the interned version.

I use compute_const both in FulfillProcessor::process_obligation and wf::predicate_obligations. Is this required?

process_obligation uses wf::obligations, doesn't it?
I would expect you'd need to add a wf::const_obligations that's like wf::obligations but takes ty::Const and uses compute_const, sorry I wasn't clear about that, just looked at the code now.

@@ -1535,6 +1541,7 @@ where
Types(I),
InputTypes(J),
ProjectionTypes(K),
WellFormedConst(Ty<'tcx>, I),
Copy link
Member

@eddyb eddyb Mar 19, 2020

Choose a reason for hiding this comment

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

Predicate::walk_tys is even more cursed than Ty::walk, wow. At least I think your approach here is okay for now.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, #70164 removes walk_tys completely, it was a rustdoc-only fragile hack.

@lcnr lcnr changed the title Revert compute_const changes in WF add const WF predicate Mar 19, 2020
@nikomatsakis
Copy link
Contributor

It looks like it got canceled?

@varkor
Copy link
Member

varkor commented Jun 3, 2020

Let's assume this was spurious.

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Jun 3, 2020

📌 Commit 631ac9c has been approved by eddyb

@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 Jun 3, 2020
@bors
Copy link
Contributor

bors commented Jun 3, 2020

⌛ Testing commit 631ac9c with merge ff4aff6...

@bors
Copy link
Contributor

bors commented Jun 3, 2020

☀️ Test successful - checks-azure
Approved by: eddyb
Pushing ff4aff6 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 3, 2020
@bors bors merged commit ff4aff6 into rust-lang:master Jun 3, 2020
@lcnr lcnr deleted the issue68977 branch June 3, 2020 12:23
This was referenced Jun 3, 2020
@Mark-Simulacrum
Copy link
Member

This looks like it caused a pretty major regression in wall times (that has held up for some time now) -- https://perf.rust-lang.org/compare.html?start=680a4b2fbdca0dc6c5ceec826a8dbeabe28f305d&end=ff4aff6ce0f216c8cb8d40f432efaacdaca8095b&stat=wall-time -- most of those are tiny deltas but given that they've held up I suspect that this is indeed the cause. We don't observe a similar increase in instruction counts though.

I don't see a perf run on this PR; was this expected?

@lcnr
Copy link
Contributor Author

lcnr commented Jun 5, 2020

We ran perf in https://perf.rust-lang.org/compare.html?start=783139bd8fc3b94fac9a1bf81bba2c506e8221b6&end=eb0cfcd08d428eeeced6db60ee25d022715932de which looked fairly innocent to me.

So this change is not expected 😅

@Mark-Simulacrum
Copy link
Member

Hm interesting! It might have also been a change upstream somewhere as we have been recently reworking some of the collector and frontend backends. Would you be up for posting a revert that we can run perf on to see if that recovers performance?

@varkor
Copy link
Member

varkor commented Jun 14, 2020

@slightlyoutofphase: unfortunately, without this check, const generic would be unsound. The problem is really that const generics is incomplete and we're missing some critical components that are necessary to get them working properly. Const generics is unstable ("very unstable" in some sense in that it explicitly warns you things may break if you try to use them at the moment). We're grateful to have people testing them so that we can address the flaws before stabilising the feature, but we haven't yet reached the point where we can guarantee any kind of stability. Hopefully that will change before too long :)

@jswrenn
Copy link
Member

jswrenn commented Jul 1, 2020

unfortunately, without this check, const generic would be unsound

@varkor is this unsound for fundamental reasons, or unsound merely because of temporary implementation shortcomings?

I'm interested in the implement-a-trait-if-a-const-predicate-is-satisfied pattern because it has the potential to let me replace typic's type-level computations with plain old Rust. I'm curious whether this pattern will ever be soundly supported.

@varkor
Copy link
Member

varkor commented Jul 1, 2020

Const generics would be unsound without this check. However, there should be a way to modify the code slightly to make these now-failing examples work: it's just that we haven't worked out the right way to do it yet. See this issue for more details: #68436.

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)]` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revert compute_const changes in WF