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

Lazy normalization of constants #67890

Conversation

BenLewis-Seequent
Copy link

@BenLewis-Seequent BenLewis-Seequent commented Jan 5, 2020

Based on #67717

Initial implementation of #60471 for constants.

Perform normalization/evaluation of constants lazily, which is known as lazy normalization. Lazy normalization is only enabled given the command line flag -Z lazy-normalization, by default constants are still evaluated eagerly as there are currently.

Lazy normalization of constants is achieved with a new ConstEquate predicate which type inferences uses to delay checking whether constants are equal to each other until later, avoiding cycle errors.

Note this doesn't allow the use of generics within repeat count expressions as that is still evaluated during conversion to mir. There are also quite a few other known problems with lazy normalization which I'm planning to fix in follow up PRs.

r? @nikomatsakis cc @varkor

@JohnTitor JohnTitor added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 5, 2020
@Centril Centril added F-const_generics `#![feature(const_generics)]` A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) labels Jan 5, 2020
@@ -948,4 +948,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
(such as entering an empty infinite loop) by inserting llvm.sideeffect"),
deduplicate_diagnostics: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
"deduplicate identical diagnostics"),
lazy_normalization: bool = (false, parse_bool, [UNTRACKED],
"lazily evaluate constants (experimental)"),
Copy link
Contributor

Choose a reason for hiding this comment

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

-Z flags are less convenient to experiment with, e.g. on the playground (to find bugs and whatnot), so why not use a feature gate?

Copy link
Member

Choose a reason for hiding this comment

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

It might be useful to have both. A -Z flag will allow turning on lazy normalization for an entire crate graph, via RUSTFLAGS

Copy link
Author

Choose a reason for hiding this comment

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

My thinking was that this doesn't just affect code that uses the const generic feature, so having a -Z flag would be useful to test non-feature gated crates. Though enabling it also with a feature gate would also be good, as I had to partially already do that to get the impls inside the standard library that use const generics to work.

Copy link
Author

Choose a reason for hiding this comment

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

tidy is complaining that there is no gate test for this feature, how would I write a gate test for this? Detecting when this feature is needed is very hard, as evident by the previously poor diagnostics/ICEs.

Also is there a way to enable a feature via RUSTFLAGS? I don't want to check for both whether the feature is enabled and the debugging option, every time I check if lazy normalization is enabled.

Copy link
Member

@varkor varkor left a comment

Choose a reason for hiding this comment

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

The implementation looks good to me, pending #67717. The work you've been doing on const generics / lazy normalisation is brilliant ❤️

cc @eddyb

src/librustc/infer/combine.rs Outdated Show resolved Hide resolved
src/librustc/ty/mod.rs Outdated Show resolved Hide resolved
src/librustc/ty/relate.rs Outdated Show resolved Hide resolved
src/librustc/ty/relate.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Jan 6, 2020

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

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

Ping from triage: @Skinny121 can you please address the merge conflicts?

@varkor varkor added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 19, 2020
@varkor
Copy link
Member

varkor commented Jan 19, 2020

This is blocked on #67717.

@BenLewis-Seequent
Copy link
Author

Blocked on #68505, now instead.

@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-02-29T00:03:15.4686915Z ========================== Starting Command Output ===========================
2020-02-29T00:03:15.4706966Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/cda7209e-779c-483b-b775-66f899cc3e5b.sh
2020-02-29T00:03:15.4871434Z 
2020-02-29T00:03:15.4926574Z ##[section]Finishing: Disable git automatic line ending conversion
2020-02-29T00:03:15.4949295Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/67890/merge to s
2020-02-29T00:03:15.4954124Z Task         : Get sources
2020-02-29T00:03:15.4954592Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-02-29T00:03:15.4955024Z Version      : 1.0.0
2020-02-29T00:03:15.4955203Z Author       : Microsoft
---
2020-02-29T00:03:16.2888968Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-02-29T00:03:16.2941015Z ##[command]git config gc.auto 0
2020-02-29T00:03:16.2973999Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-02-29T00:03:16.3004964Z ##[command]git config --get-all http.proxy
2020-02-29T00:03:16.3251082Z ##[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/67890/merge:refs/remotes/pull/67890/merge

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)

@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-02-29T02:27:55.2488052Z ========================== Starting Command Output ===========================
2020-02-29T02:27:55.2491874Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/c23767f7-2592-46f0-b476-59446e4cebb6.sh
2020-02-29T02:27:55.2492230Z 
2020-02-29T02:27:55.2496346Z ##[section]Finishing: Disable git automatic line ending conversion
2020-02-29T02:27:55.2516419Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/67890/merge to s
2020-02-29T02:27:55.2519630Z Task         : Get sources
2020-02-29T02:27:55.2519906Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-02-29T02:27:55.2520245Z Version      : 1.0.0
2020-02-29T02:27:55.2520429Z Author       : Microsoft
---
2020-02-29T02:27:56.7382547Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-02-29T02:27:56.7389279Z ##[command]git config gc.auto 0
2020-02-29T02:27:56.7392846Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-02-29T02:27:56.7396124Z ##[command]git config --get-all http.proxy
2020-02-29T02:27:56.7403749Z ##[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/67890/merge:refs/remotes/pull/67890/merge
---
2020-02-29T02:34:56.0440596Z     Finished release [optimized] target(s) in 1m 34s
2020-02-29T02:34:56.0544339Z tidy check
2020-02-29T02:34:57.4762949Z * 590 error codes
2020-02-29T02:34:57.4763808Z * highest error code: E0747
2020-02-29T02:34:57.8796569Z Expected a gate test for the feature 'lazy_normalization_consts'.
2020-02-29T02:34:57.8797219Z Hint: create a failing test file named 'feature-gate-lazy_normalization_consts.rs'
2020-02-29T02:34:57.8797786Z       in the 'ui' test suite, with its failures due to
2020-02-29T02:34:57.8798132Z       missing usage of `#![feature(lazy_normalization_consts)]`.
2020-02-29T02:34:57.8798652Z Hint: If you already have such a test and don't want to rename it,
2020-02-29T02:34:57.8800110Z       you can also add a // gate-test-lazy_normalization_consts line to the test file.
2020-02-29T02:34:57.8800540Z tidy error: Found 1 features without a gate test.
2020-02-29T02:34:58.8583821Z Found 488 error codes
2020-02-29T02:34:58.8600112Z Found 0 error codes with no tests
2020-02-29T02:34:58.8600727Z Done!
2020-02-29T02:34:58.8601244Z some tidy checks failed
2020-02-29T02:34:58.8601244Z some tidy checks failed
2020-02-29T02:34:58.8601526Z 
2020-02-29T02:34:58.8601751Z 
2020-02-29T02:34:58.8603519Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor"
2020-02-29T02:34:58.8605002Z 
2020-02-29T02:34:58.8605544Z 
2020-02-29T02:34:58.8611469Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2020-02-29T02:34:58.8612196Z Build completed unsuccessfully in 0:01:46
2020-02-29T02:34:58.8612196Z Build completed unsuccessfully in 0:01:46
2020-02-29T02:34:58.8645370Z == clock drift check ==
2020-02-29T02:34:58.8675574Z   local time: Sat Feb 29 02:34:58 UTC 2020
2020-02-29T02:34:59.1553922Z   network time: Sat, 29 Feb 2020 02:34:59 GMT
2020-02-29T02:34:59.1557889Z == end clock drift check ==
2020-02-29T02:34:59.9436855Z 
2020-02-29T02:34:59.9528510Z ##[error]Bash exited with code '1'.
2020-02-29T02:34:59.9544024Z ##[section]Finishing: Run build
2020-02-29T02:34:59.9591647Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/67890/merge to s
2020-02-29T02:34:59.9596907Z Task         : Get sources
2020-02-29T02:34:59.9597261Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-02-29T02:34:59.9597739Z Version      : 1.0.0
2020-02-29T02:34:59.9597966Z Author       : Microsoft
2020-02-29T02:34:59.9597966Z Author       : Microsoft
2020-02-29T02:34:59.9598324Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-02-29T02:34:59.9598725Z ==============================================================================
2020-02-29T02:35:00.3129093Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-02-29T02:35:00.3174690Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/67890/merge to s
2020-02-29T02:35:00.3264502Z Cleaning up task key
2020-02-29T02:35:00.3265766Z Start cleaning up orphan processes.
2020-02-29T02:35:00.3445671Z Terminate orphan process: pid (4046) (python)
2020-02-29T02:35:00.3613716Z ##[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 @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Mar 3, 2020

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

@vadixidav
Copy link
Contributor

vadixidav commented Mar 4, 2020

It looks like this is unblocked now, since #68505 is now merged.

Edit: Nevermind me, I see that commits are already happening. I didn't see those.

@mark-i-m
Copy link
Member

@rustbot modify labels: -S-blocked +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Mar 16, 2020
@alexreg
Copy link
Contributor

alexreg commented Mar 16, 2020

Is this blocked on something new?

@joelpalmer joelpalmer removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 2, 2020
@eddyb
Copy link
Member

eddyb commented Apr 10, 2020

@mati865 There you go, if you need this again PM me on Discord/Zulip.

@rust-highfive
Copy link
Collaborator

The job mingw-check 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-04-10T20:57:33.7670462Z ========================== Starting Command Output ===========================
2020-04-10T20:57:33.7676021Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/54cbe80a-f8b2-427a-b926-87bb7e065b9e.sh
2020-04-10T20:57:33.7676545Z 
2020-04-10T20:57:33.7682033Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-10T20:57:33.7702236Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/67890/merge to s
2020-04-10T20:57:33.7705787Z Task         : Get sources
2020-04-10T20:57:33.7706088Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T20:57:33.7706377Z Version      : 1.0.0
2020-04-10T20:57:33.7706685Z Author       : Microsoft
---
2020-04-10T20:57:34.9373226Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-10T20:57:34.9380653Z ##[command]git config gc.auto 0
2020-04-10T20:57:34.9384934Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-10T20:57:34.9388957Z ##[command]git config --get-all http.proxy
2020-04-10T20:57:34.9397542Z ##[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/67890/merge:refs/remotes/pull/67890/merge
---
2020-04-10T21:00:02.2668403Z  ---> 78ad2f4d4aca
2020-04-10T21:00:02.2668649Z Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
2020-04-10T21:00:02.2669053Z  ---> Using cache
2020-04-10T21:00:02.2669387Z  ---> 4d2dc61c4d00
2020-04-10T21:00:02.2671246Z Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            /scripts/validate-toolstate.sh
2020-04-10T21:00:02.2673065Z  ---> 776b6266a8b7
2020-04-10T21:00:02.2673442Z Successfully built 776b6266a8b7
2020-04-10T21:00:02.2708313Z Successfully tagged rust-ci:latest
2020-04-10T21:00:02.3019290Z Built container sha256:776b6266a8b7d63e2d3c2b5a784dbf521184a904fb10bf818c6b5c7e1ab74d4a
2020-04-10T21:00:02.3019290Z Built container sha256:776b6266a8b7d63e2d3c2b5a784dbf521184a904fb10bf818c6b5c7e1ab74d4a
2020-04-10T21:00:02.3035619Z Looks like docker image is the same as before, not uploading
2020-04-10T21:00:02.9486974Z [CI_JOB_NAME=mingw-check]
2020-04-10T21:00:02.9791163Z [CI_JOB_NAME=mingw-check]
2020-04-10T21:00:02.9890804Z == clock drift check ==
2020-04-10T21:00:02.9900735Z   local time: Fri Apr 10 21:00:02 UTC 2020
2020-04-10T21:00:03.1907192Z   network time: Fri, 10 Apr 2020 21:00:03 GMT
2020-04-10T21:00:03.1914118Z Starting sccache server...
2020-04-10T21:00:03.3097575Z configure: processing command line
2020-04-10T21:00:03.3097893Z configure: 
2020-04-10T21:00:03.3099007Z configure: rust.parallel-compiler := True
---
2020-04-10T21:04:16.5312919Z     Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-10T21:04:16.5667775Z     Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-10T21:04:16.8057849Z     Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-10T21:04:16.9851065Z     Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-10T21:04:17.5882879Z     Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-10T21:04:20.3148220Z     Checking rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-10T21:04:20.8847269Z     Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-10T21:04:23.3769665Z     Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-10T21:04:23.8648095Z     Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-10T21:06:25.0999121Z configure: build.locked-deps    := True
2020-04-10T21:06:25.1006259Z configure: rust.codegen-units-std := 1
2020-04-10T21:06:25.1007195Z configure: rust.verify-llvm-ir  := True
2020-04-10T21:06:25.1007909Z configure: rust.channel         := nightly
2020-04-10T21:06:25.1008726Z configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
2020-04-10T21:06:25.1009540Z configure: writing `config.toml` in current directory
2020-04-10T21:06:25.1009909Z configure: 
2020-04-10T21:06:25.1010456Z configure: run `python /checkout/x.py --help`
2020-04-10T21:06:25.1010840Z configure: 
---
2020-04-10T21:08:08.8462741Z Hugepagesize:       2048 kB
2020-04-10T21:08:08.8462986Z DirectMap4k:      143296 kB
2020-04-10T21:08:08.8463209Z DirectMap2M:     3002368 kB
2020-04-10T21:08:08.8463433Z DirectMap1G:     6291456 kB
2020-04-10T21:08:08.8488748Z + python3 ../x.py test src/tools/expand-yaml-anchors
2020-04-10T21:08:10.3812458Z Ensuring the YAML anchors in the GitHub Actions config were expanded
2020-04-10T21:08:10.3812458Z Ensuring the YAML anchors in the GitHub Actions config were expanded
2020-04-10T21:08:10.3820239Z Building stage0 tool expand-yaml-anchors (x86_64-unknown-linux-gnu)
2020-04-10T21:08:10.6396836Z    Compiling unicode-xid v0.2.0
2020-04-10T21:08:10.7751303Z    Compiling syn v1.0.11
2020-04-10T21:08:11.7436807Z    Compiling linked-hash-map v0.5.2
2020-04-10T21:08:11.7723129Z    Compiling lazy_static v1.4.0
2020-04-10T21:08:11.7723129Z    Compiling lazy_static v1.4.0
2020-04-10T21:08:12.0126543Z    Compiling yaml-rust v0.4.3
2020-04-10T21:08:16.9767120Z    Compiling quote v1.0.2
2020-04-10T21:08:33.1478777Z    Compiling thiserror-impl v1.0.5
2020-04-10T21:08:38.4455374Z    Compiling thiserror v1.0.5
2020-04-10T21:08:38.5088868Z    Compiling yaml-merge-keys v0.4.0
2020-04-10T21:08:39.8246398Z    Compiling expand-yaml-anchors v0.1.0 (/checkout/src/tools/expand-yaml-anchors)
2020-04-10T21:08:41.6185781Z Build completed successfully in 0:00:32
2020-04-10T21:08:41.6282337Z + python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu
2020-04-10T21:08:41.9168788Z     Finished dev [unoptimized] target(s) in 0.19s
2020-04-10T21:08:43.1083414Z Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> i686-pc-windows-gnu)
---
2020-04-10T21:11:06.2068757Z     Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-10T21:11:06.4561652Z     Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-10T21:11:06.6843773Z     Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-10T21:11:06.7094714Z     Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-10T21:11:07.4140490Z     Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-10T21:11:10.0455405Z     Checking rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-10T21:11:10.6155380Z     Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-10T21:11:13.0949501Z     Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-10T21:11:13.6555460Z     Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-10T21:15:22.8256654Z    Compiling cargo_metadata v0.9.1
2020-04-10T21:15:27.9109799Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2020-04-10T21:15:39.6609544Z     Finished release [optimized] target(s) in 27.82s
2020-04-10T21:15:39.6713994Z tidy check
2020-04-10T21:15:42.6097613Z tidy error: /checkout/src/librustc_feature/active.rs:561: trailing whitespace
2020-04-10T21:15:42.9163265Z tidy error: /checkout/src/librustc_trait_selection/traits/error_reporting/mod.rs:561: trailing whitespace
2020-04-10T21:15:44.1445215Z tidy error: Found 1 features without a gate test.
2020-04-10T21:15:44.1446316Z Expected a gate test for the feature 'lazy_normalization_consts'.
2020-04-10T21:15:44.1447030Z Hint: create a failing test file named 'feature-gate-lazy_normalization_consts.rs'
2020-04-10T21:15:44.1447650Z       in the 'ui' test suite, with its failures due to
2020-04-10T21:15:44.1447990Z       missing usage of `#![feature(lazy_normalization_consts)]`.
2020-04-10T21:15:44.1448856Z Hint: If you already have such a test and don't want to rename it,
2020-04-10T21:15:44.1449467Z       you can also add a // gate-test-lazy_normalization_consts line to the test file.
2020-04-10T21:15:47.7399374Z Found 490 error codes
2020-04-10T21:15:47.7399664Z Found 0 error codes with no tests
2020-04-10T21:15:47.7399857Z Done!
2020-04-10T21:15:47.7400052Z some tidy checks failed
2020-04-10T21:15:47.7400052Z some tidy checks failed
2020-04-10T21:15:47.7400200Z 
2020-04-10T21:15:47.7400301Z 
2020-04-10T21:15:47.7401889Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo"
2020-04-10T21:15:47.7402672Z 
2020-04-10T21:15:47.7402773Z 
2020-04-10T21:15:47.7403044Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2020-04-10T21:15:47.7403438Z Build completed unsuccessfully in 0:00:37
2020-04-10T21:15:47.7403438Z Build completed unsuccessfully in 0:00:37
2020-04-10T21:15:47.7513375Z == clock drift check ==
2020-04-10T21:15:47.7526736Z   local time: Fri Apr 10 21:15:47 UTC 2020
2020-04-10T21:15:48.0801421Z   network time: Fri, 10 Apr 2020 21:15:47 GMT
2020-04-10T21:15:50.4021743Z 
2020-04-10T21:15:50.4021743Z 
2020-04-10T21:15:50.4108676Z ##[error]Bash exited with code '1'.
2020-04-10T21:15:50.4122705Z ##[section]Finishing: Run build
2020-04-10T21:15:50.4173089Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/67890/merge to s
2020-04-10T21:15:50.4178246Z Task         : Get sources
2020-04-10T21:15:50.4178613Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T21:15:50.4178958Z Version      : 1.0.0
2020-04-10T21:15:50.4179185Z Author       : Microsoft
2020-04-10T21:15:50.4179185Z Author       : Microsoft
2020-04-10T21:15:50.4179557Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-10T21:15:50.4180021Z ==============================================================================
2020-04-10T21:15:50.7793234Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-10T21:15:50.7840114Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/67890/merge to s
2020-04-10T21:15:50.7938073Z Cleaning up task key
2020-04-10T21:15:50.7939556Z Start cleaning up orphan processes.
2020-04-10T21:15:50.8140628Z Terminate orphan process: pid (3884) (python)
2020-04-10T21:15:50.8327830Z ##[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)

@mati865
Copy link
Contributor

mati865 commented Apr 11, 2020

FTR here is backup of original commits: master...mati865:lazy-norm-anon-const-bck

@eddyb
Copy link
Member

eddyb commented Apr 11, 2020

FWIW GitHub also remembers it, to some extent, see #67890 (comment).

@eddyb force-pushed the skinny121:lazy-norm-anon-const branch from 8e19004fd4fd2c26d5583ccaae2cf0b0395aadb7 to 905e64b 17 hours ago

@mati865
Copy link
Contributor

mati865 commented Apr 11, 2020

@eddyb AFAIK dropped commits are garbage collected after some time. Better safe than sorry.

@bors
Copy link
Contributor

bors commented Apr 12, 2020

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

@mark-i-m
Copy link
Member

It looks like another rebase is needed and tidy is failing:

src/librustc_feature/active.rs:561: trailing whitespace
src/librustc_trait_selection/traits/error_reporting/mod.rs:561: trailing whitespace
tidy error: Found 1 features without a gate test.
Expected a gate test for the feature 'lazy_normalization_consts'.
Hint: create a failing test file named 'feature-gate-lazy_normalization_consts.rs'
in the 'ui' test suite, with its failures due to
missing usage of `#![feature(lazy_normalization_consts)]`.
Hint: If you already have such a test and don't want to rename it,
you can also add a // gate-test-lazy_normalization_consts line to the test file.

@joelpalmer joelpalmer added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 28, 2020
@lcnr
Copy link
Contributor

lcnr commented May 5, 2020

Will try and get this ready again

@lcnr
Copy link
Contributor

lcnr commented May 5, 2020

I managed to fix all problems (at least locally) in https://github.com/lcnr/rust/tree/lazy-norm!

Can someone force push my branch onto this PR?

The ICE was caused by accidentally removed const.super_fold calls, which I added back in.

@lcnr
Copy link
Contributor

lcnr commented May 5, 2020

This now fixes and tests #61935, which solves

Expected a gate test for the feature 'lazy_normalization_consts'.

@varkor
Copy link
Member

varkor commented May 5, 2020

@nikomatsakis: ping for review (#67890 (comment)).

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Left some notes from my first read. I think that tonight I will kick off a local build so I can play with this code a bit locally.

@@ -603,8 +606,8 @@ where
b = self.infcx.shallow_resolve(b);
}

match b.val {
ty::ConstKind::Infer(InferConst::Var(_)) if D::forbid_inference_vars() => {
match (a.val, b.val) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: seems like a useful diff?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite sure what you mean here 🤔 This does not change the actual behavior afaict which is why I removed this change in #71973.

@@ -408,6 +408,7 @@ symbols! {
label_break_value,
lang,
lang_items,
lazy_normalization_consts,
Copy link
Contributor

Choose a reason for hiding this comment

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

(Do we really want a separate feature for this?)

Copy link
Contributor

@lcnr lcnr May 7, 2020

Choose a reason for hiding this comment

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

We already use const generics in libcore/libstd, so it might be better to not use lazy normalization there for now. I can go ahead and restrict these changes on const_generics instead though.

Copy link
Member

Choose a reason for hiding this comment

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

We do want two features: lazy normalisation unblocks some issues even without const generics. We probably do always want lazy normalisation enabled when const generics is, though. (But I think this is the current effect anyway?)

Copy link
Contributor

Choose a reason for hiding this comment

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

(But I think this is the current effect anyway?)

No, rn lazy normalization is checked separately from const generics, so we need to enable both to use it.
Considering that we still eagerly normalize array lengths, I don't actually know how to use this on stable.

}
}
}
// FIXME(skinny121) How to report both errors if both produces errors?
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm so here we report no errors...

Copy link
Contributor

Choose a reason for hiding this comment

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

evaluate only returns ProcessResult::Error if const_eval_resolve returns ErrorHandled::Reported afaict. This comment seems outdated, will make this more explicit.

Err(_) => Ok(EvaluatedToErr),
}
}

ty::Predicate::ConstEquate(c1, c2) => {
debug!("evaluate_predicate_recursively: equating consts c1={:?} c2={:?}", c1, c2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm we should try to factor a helper to share the code between this and fulfill.rs

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried and failed. 😅 the evaluate closures are different enough that my approaches at extracting part of them into a shared function ended up making the code worse :/

(ty::ConstKind::Unevaluated(..), _)
if self.tcx.features().lazy_normalization_consts =>
{
relation.const_equate_obligation(a, b);
Copy link
Contributor

Choose a reason for hiding this comment

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

Until we get the full universe transition happening here, I think we want to check that there are no escaping late-bound regions in these types...oh, hmm, I guess they would be substituted for placeholders already...urgh.

_ => relate::super_relate_consts(self, c, c),
}
}
}

pub trait ConstEquateRelation<'tcx>: TypeRelation<'tcx> {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not obvious to me at this moment why we have a distinct trait for this

Copy link
Contributor

Choose a reason for hiding this comment

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

There are someTypeRelations which don't need fn const_equate_obligation atm, so I ended up adding a bunch of unimplementeds while moving fn const_equate_obligation to TypeRelation.

I slightly prefer keeping the ConstEquateRelation trait for now. Depending on your preference I would drop the last commit of #71973, which merges these two traits. See deaa50e

@nikomatsakis
Copy link
Contributor

Question: should we close this PR and re-open one from @lcnr's branch, if they're maintaining this? It seems more natural (we can of course add @Skinny121 as co-author on the commits).

@lcnr
Copy link
Contributor

lcnr commented May 7, 2020

Using my branch directly is a lot easier for me at least 😆 I opened #71973 for now.

@nikomatsakis not sure how to deal with your already started review here, will try to either fix/answer them here or copy them to my new PR

@nikomatsakis
Copy link
Contributor

@lcnr ok, I'll move over to that branch -- I can try to move my comments over

@nikomatsakis
Copy link
Contributor

Closing in favor of #71973

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 18, 2020
Lazy normalization of constants (Reprise)

Continuation of rust-lang#67890 by @Skinny121.

Initial implementation of rust-lang#60471 for constants.

Perform normalization/evaluation of constants lazily, which is known as lazy normalization. Lazy normalization is only enabled when using `#![feature(lazy_normalization_consts)]`, by default constants are still evaluated eagerly as there are currently.

Lazy normalization of constants is achieved with a new ConstEquate predicate which type inferences uses to delay checking whether constants are equal to each other until later, avoiding cycle errors.

Note this doesn't allow the use of generics within repeat count expressions as that is still evaluated during conversion to mir. There are also quite a few other known problems with lazy normalization which will be fixed in future PRs.

r? @nikomatsakis

fixes rust-lang#71922, fixes rust-lang#71986
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 18, 2020
Lazy normalization of constants (Reprise)

Continuation of rust-lang#67890 by @Skinny121.

Initial implementation of rust-lang#60471 for constants.

Perform normalization/evaluation of constants lazily, which is known as lazy normalization. Lazy normalization is only enabled when using `#![feature(lazy_normalization_consts)]`, by default constants are still evaluated eagerly as there are currently.

Lazy normalization of constants is achieved with a new ConstEquate predicate which type inferences uses to delay checking whether constants are equal to each other until later, avoiding cycle errors.

Note this doesn't allow the use of generics within repeat count expressions as that is still evaluated during conversion to mir. There are also quite a few other known problems with lazy normalization which will be fixed in future PRs.

r? @nikomatsakis

fixes rust-lang#71922, fixes rust-lang#71986
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jul 1, 2020
remove duplicate test for rust-lang#61935

Apparently I somehow messed up the issue number in rust-lang#67890
which caused us to add this test twice, both as https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/issues/issue-61935.rs and https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/lazy-normalization/issue-71922.rs

rust-lang#61935 is the actually fixed issue while rust-lang#71922 is still not working, as it depends on lazy norm of repeat expressions
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 1, 2020
remove duplicate test for rust-lang#61935

Apparently I somehow messed up the issue number in rust-lang#67890
which caused us to add this test twice, both as https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/issues/issue-61935.rs and https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/lazy-normalization/issue-71922.rs

rust-lang#61935 is the actually fixed issue while rust-lang#71922 is still not working, as it depends on lazy norm of repeat expressions
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 2, 2020
remove duplicate test for rust-lang#61935

Apparently I somehow messed up the issue number in rust-lang#67890
which caused us to add this test twice, both as https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/issues/issue-61935.rs and https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/lazy-normalization/issue-71922.rs

rust-lang#61935 is the actually fixed issue while rust-lang#71922 is still not working, as it depends on lazy norm of repeat expressions
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 2, 2020
remove duplicate test for rust-lang#61935

Apparently I somehow messed up the issue number in rust-lang#67890
which caused us to add this test twice, both as https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/issues/issue-61935.rs and https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/lazy-normalization/issue-71922.rs

rust-lang#61935 is the actually fixed issue while rust-lang#71922 is still not working, as it depends on lazy norm of repeat expressions
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 2, 2020
remove duplicate test for rust-lang#61935

Apparently I somehow messed up the issue number in rust-lang#67890
which caused us to add this test twice, both as https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/issues/issue-61935.rs and https://github.com/rust-lang/rust/blob/master/src/test/ui/const-generics/lazy-normalization/issue-71922.rs

rust-lang#61935 is the actually fixed issue while rust-lang#71922 is still not working, as it depends on lazy norm of repeat expressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) F-const_generics `#![feature(const_generics)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.