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

Implement dataflow-based const validation #64470

Merged
merged 31 commits into from Sep 29, 2019

Conversation

@ecstatic-morse
Copy link
Contributor

commented Sep 14, 2019

This PR adds a separate, dataflow-enabled pass that checks the bodies of consts, statics and const fns for const safety. This is based on my work in #63860, which tried to integrate into the existing pass in qualify_consts.rs. However, the resulting pass was even more unwieldy than the original. Unlike its predecessor, this PR is designed to be combined with #63812 to replace the existing pass completely.

The new checker lives in librustc_mir/transform/check_consts.

qualifs.rs contains small modifications to the existing Qualif trait and its implementors, but is mostly unchanged except for the removal of IsNotPromotable and IsNotImplicitlyPromotable, which are only necessary for promotion.

resolver.rs contains the dataflow analysis used to propagate qualifs between locals.

Finally, validation.rs contains a refactored version of the existing Visitor in qualfy_consts.rs. All errors have been associated with a struct to make comparison with the existing pass simple.

The existing validation logic in qualify_consts has been modified to allow it to run in parallel with the new validator. If use_new_validator is not set, the old validation will be responsible for actually generating the errors, but those errors can be compared with the ones from the new validator.

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Sep 14, 2019

r? @zackmdavis

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

@ecstatic-morse

This comment has been minimized.

Copy link
Contributor Author

commented Sep 14, 2019

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned zackmdavis Sep 14, 2019
@ecstatic-morse

This comment was marked as resolved.

Copy link
Contributor Author

commented Sep 14, 2019

The code that compares results with the previous pass does not belong in the final product, hence the draft PR status.

Additionally, I think I want to adopt a more conservative approach to handling indirect assignments during dataflow. Currently, we wait until an indirect assignment (e.g. opaque function call, custom Drop impl, or write through an indirection) to qualify all locals whose address has been borrowed and whose type can possibly contain that Qualif. Instead, I think we should assume that as soon as a mutable reference (or shared reference if the type has interior mutability) is taken to a local, it takes on all possible qualifiers for its type. This will simplify dataflow analysis, and is closer to the old code.

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from 17b52c5 to 797a2c2 Sep 15, 2019
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Sep 15, 2019

The job x86_64-gnu-llvm-6.0 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.
2019-09-15T05:36:59.0234459Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-15T05:36:59.0433326Z ##[command]git config gc.auto 0
2019-09-15T05:36:59.0530502Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-15T05:36:59.0588791Z ##[command]git config --get-all http.proxy
2019-09-15T05:36:59.0778536Z ##[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/64470/merge:refs/remotes/pull/64470/merge
---
2019-09-15T06:42:41.7625473Z ...........................................................F........................................ 1500/9018
2019-09-15T06:42:47.9270437Z .................................................................................................... 1600/9018
2019-09-15T06:43:01.1887799Z ............................................................i...............i....................... 1700/9018
2019-09-15T06:43:09.1638823Z .................................................................................................... 1800/9018
2019-09-15T06:43:24.9624999Z ...................................................iiiii............................................ 1900/9018
2019-09-15T06:43:36.7826119Z .................................................................................................... 2100/9018
2019-09-15T06:43:39.4879615Z .................................................................................................... 2200/9018
2019-09-15T06:43:43.1551273Z .................................................................................................... 2300/9018
2019-09-15T06:43:51.8324230Z .................................................................................................... 2400/9018
---
2019-09-15T06:46:58.5395469Z .......................................i...............i............................................ 4700/9018
2019-09-15T06:47:10.8122367Z .................................................................................................... 4800/9018
2019-09-15T06:47:17.7797136Z .................................................................................................... 4900/9018
2019-09-15T06:47:28.4286473Z .................................................................................................... 5000/9018
2019-09-15T06:47:35.5543446Z .......................ii.ii........................................................................ 5100/9018
2019-09-15T06:47:46.4756823Z .................................................................................................... 5300/9018
2019-09-15T06:47:57.0650251Z .......................................................................................i............ 5400/9018
2019-09-15T06:48:05.5215601Z .................................................................................................... 5500/9018
2019-09-15T06:48:11.2091347Z .................................................................................................... 5600/9018
2019-09-15T06:48:11.2091347Z .................................................................................................... 5600/9018
2019-09-15T06:48:21.9822917Z ..................................................................................ii...i..ii........ 5700/9018
2019-09-15T06:48:48.5348349Z .................................................................................................... 5900/9018
2019-09-15T06:48:59.1154685Z .................................................................................................... 6000/9018
2019-09-15T06:48:59.1154685Z .................................................................................................... 6000/9018
2019-09-15T06:49:08.3890733Z ....................................................................................i..ii........... 6100/9018
2019-09-15T06:49:42.3876937Z .................................................................................................... 6300/9018
2019-09-15T06:49:45.0292481Z ...........................................i........................................................ 6400/9018
2019-09-15T06:49:47.3781218Z .................................................................................................... 6500/9018
2019-09-15T06:49:50.0954427Z ...............i.................................................................................... 6600/9018
---
2019-09-15T06:54:06.3328826Z 1 error[E0019]: constant contains unimplemented expression type
2019-09-15T06:54:06.3329407Z -   --> $DIR/const-if.rs:1:20
2019-09-15T06:54:06.3329968Z +   --> $DIR/const-if.rs:1:19
2019-09-15T06:54:06.3330274Z 3    |
2019-09-15T06:54:06.3330791Z - LL | const _X: i32 = if true { 5 } else { 6 };
2019-09-15T06:54:06.3331326Z -    |                    ^^^^
2019-09-15T06:54:06.3331622Z + LL | const _: i32 = if true { 5 } else { 6 };
2019-09-15T06:54:06.3332128Z 6 
2019-09-15T06:54:06.3332347Z 7 error[E0019]: constant contains unimplemented expression type
2019-09-15T06:54:06.3332844Z -   --> $DIR/const-if.rs:1:17
2019-09-15T06:54:06.3333364Z +   --> $DIR/const-if.rs:1:16
2019-09-15T06:54:06.3333364Z +   --> $DIR/const-if.rs:1:16
2019-09-15T06:54:06.3333652Z 9    |
2019-09-15T06:54:06.3334490Z - LL | const _X: i32 = if true { 5 } else { 6 };
2019-09-15T06:54:06.3335149Z -    |                 ^^^^^^^^^^^^^^^^^^^^^^^^
2019-09-15T06:54:06.3335485Z + LL | const _: i32 = if true { 5 } else { 6 };
2019-09-15T06:54:06.3335943Z 12 
2019-09-15T06:54:06.3336181Z 13 error: aborting due to 2 previous errors
2019-09-15T06:54:06.3336424Z 14 
2019-09-15T06:54:06.3336619Z 
2019-09-15T06:54:06.3336619Z 
2019-09-15T06:54:06.3336813Z 
2019-09-15T06:54:06.3337064Z The actual stderr differed from the expected stderr.
2019-09-15T06:54:06.3337605Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-if/const-if.stderr
2019-09-15T06:54:06.3338225Z To update references, rerun the tests and pass the `--bless` flag
2019-09-15T06:54:06.3338871Z To only update this specific test, also pass `--test-args consts/const-if.rs`
2019-09-15T06:54:06.3339426Z error: 1 errors occurred comparing output.
2019-09-15T06:54:06.3339895Z status: exit code: 1
2019-09-15T06:54:06.3339895Z status: exit code: 1
2019-09-15T06:54:06.3341065Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-if.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/consts/const-if" "-Crpath" "-O" "-Cdebuginfo=0" "-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/consts/const-if/auxiliary" "-A" "unused"
2019-09-15T06:54:06.3342014Z ------------------------------------------
2019-09-15T06:54:06.3342316Z 
2019-09-15T06:54:06.3342817Z ------------------------------------------
2019-09-15T06:54:06.3343118Z stderr:
---
2019-09-15T06:54:06.3369901Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:536:22
2019-09-15T06:54:06.3370242Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-09-15T06:54:06.3387079Z 
2019-09-15T06:54:06.3387381Z 
2019-09-15T06:54:06.3390060Z 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 -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" "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"
2019-09-15T06:54:06.3391954Z 
2019-09-15T06:54:06.3391987Z 
2019-09-15T06:54:06.3443778Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-15T06:54:06.3444189Z Build completed unsuccessfully in 1:09:36
2019-09-15T06:54:06.3444189Z Build completed unsuccessfully in 1:09:36
2019-09-15T06:54:06.3452553Z == clock drift check ==
2019-09-15T06:54:06.3468621Z   local time: Sun Sep 15 06:54:06 UTC 2019
2019-09-15T06:54:06.4347292Z   network time: Sun, 15 Sep 2019 06:54:06 GMT
2019-09-15T06:54:06.4347524Z == end clock drift check ==
2019-09-15T06:54:07.2535532Z ##[error]Bash exited with code '1'.
2019-09-15T06:54:07.2611766Z ##[section]Starting: Checkout
2019-09-15T06:54:07.2613826Z ==============================================================================
2019-09-15T06:54:07.2613921Z Task         : Get sources
2019-09-15T06:54:07.2613973Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from 797a2c2 to 691ca56 Sep 15, 2019
@ecstatic-morse

This comment was marked as resolved.

Copy link
Contributor Author

commented Sep 15, 2019

The conservative approach described above has been implemented. However, this results in a problem around moved-from values: We need to assume that a value that is HasMutInterior is also NeedsDrop since an indirect write could have mutated that local. However, HasMutInterior is not cleared on move, so code like const fn ident<T>(x: T) -> T { x } fails to compile because, although x has been moved into the return place, it is still HasMutInterior at the Drop terminator.

I believe for now we can simply ignore HasMutInterior since borrows that allow mutation are forbidden in all const contexts. We'll need to figure out a better story for this in the future though.

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from 91ff10a to 64afa84 Sep 16, 2019
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Sep 16, 2019

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.
2019-09-16T20:36:49.9393182Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-16T20:36:49.9616316Z ##[command]git config gc.auto 0
2019-09-16T20:36:49.9697732Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-16T20:36:50.0130339Z ##[command]git config --get-all http.proxy
2019-09-16T20:36:50.0308492Z ##[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/64470/merge:refs/remotes/pull/64470/merge
---
2019-09-16T20:46:42.8225416Z     Checking rustc_ast_borrowck v0.0.0 (/checkout/src/librustc_ast_borrowck)
2019-09-16T20:46:43.3431569Z error: unused variable: `location`
2019-09-16T20:46:43.3431975Z    --> src/librustc_mir/dataflow/impls/indirect_mutation.rs:138:44
2019-09-16T20:46:43.3432278Z     |
2019-09-16T20:46:43.3432594Z 138 |         if let mir::TerminatorKind::Drop { location, .. }
2019-09-16T20:46:43.3432915Z     |                                            ^^^^^^^^
2019-09-16T20:46:43.3434095Z 139 |              | mir::TerminatorKind::DropAndReplace { location, .. } = &terminator.kind {
2019-09-16T20:46:43.3434906Z     |
2019-09-16T20:46:43.3435186Z     = note: `-D unused-variables` implied by `-D warnings`
2019-09-16T20:46:43.3435445Z help: try ignoring the field
2019-09-16T20:46:43.3435658Z     |
2019-09-16T20:46:43.3435658Z     |
2019-09-16T20:46:43.3436398Z 138 |         if let mir::TerminatorKind::Drop { location: _location: _, .. }
2019-09-16T20:46:43.3447296Z 
2019-09-16T20:46:44.2317365Z     Checking rustc_codegen_utils v0.0.0 (/checkout/src/librustc_codegen_utils)
2019-09-16T20:46:44.8638659Z     Checking rustc_plugin_impl v0.0.0 (/checkout/src/librustc_plugin)
2019-09-16T20:46:45.1620365Z     Checking rustc_resolve v0.0.0 (/checkout/src/librustc_resolve)
---
2019-09-16T20:46:53.4755268Z == clock drift check ==
2019-09-16T20:46:53.4783092Z   local time: Mon Sep 16 20:46:53 UTC 2019
2019-09-16T20:46:54.0123614Z   network time: Mon, 16 Sep 2019 20:46:54 GMT
2019-09-16T20:46:54.0130788Z == end clock drift check ==
2019-09-16T20:46:55.2051905Z ##[error]Bash exited with code '1'.
2019-09-16T20:46:55.2091382Z ##[section]Starting: Checkout
2019-09-16T20:46:55.2093142Z ==============================================================================
2019-09-16T20:46:55.2093216Z Task         : Get sources
2019-09-16T20:46:55.2093264Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from 64afa84 to 3400462 Sep 16, 2019
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Sep 16, 2019

The job x86_64-gnu-llvm-6.0 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.
2019-09-16T21:20:42.4497483Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-16T21:20:42.4725592Z ##[command]git config gc.auto 0
2019-09-16T21:20:42.4807499Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-16T21:20:42.4862817Z ##[command]git config --get-all http.proxy
2019-09-16T21:20:42.5016521Z ##[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/64470/merge:refs/remotes/pull/64470/merge
---
2019-09-16T22:21:43.9233735Z .................................................................................................... 1500/9024
2019-09-16T22:21:49.8504448Z ..................................................................................F....F............ 1600/9024
2019-09-16T22:22:02.1447445Z .................................................................i...............i.................. 1700/9024
2019-09-16T22:22:09.1566601Z .................................................................................................... 1800/9024
2019-09-16T22:22:23.7381273Z ........................................................iiiii....................................... 1900/9024
2019-09-16T22:22:34.9985559Z .................................................................................................... 2100/9024
2019-09-16T22:22:37.4384223Z .................................................................................................... 2200/9024
2019-09-16T22:22:40.6161113Z .................................................................................................... 2300/9024
2019-09-16T22:22:48.7913814Z .................................................................................................... 2400/9024
---
2019-09-16T22:25:42.1643080Z ............................................i...............i....................................... 4700/9024
2019-09-16T22:25:52.3669953Z .................................................................................................... 4800/9024
2019-09-16T22:25:59.2322181Z .................................................................................................... 4900/9024
2019-09-16T22:26:08.5300648Z .................................................................................................... 5000/9024
2019-09-16T22:26:16.0339196Z ............................ii.ii................................................................... 5100/9024
2019-09-16T22:26:26.0895711Z .................................................................................................... 5300/9024
2019-09-16T22:26:36.2376171Z ............................................................................................i....... 5400/9024
2019-09-16T22:26:44.4535866Z .................................................................................................... 5500/9024
2019-09-16T22:26:49.2134695Z .................................................................................................... 5600/9024
2019-09-16T22:26:49.2134695Z .................................................................................................... 5600/9024
2019-09-16T22:26:59.6714323Z .......................................................................................ii...i..ii... 5700/9024
2019-09-16T22:27:24.7627987Z .................................................................................................... 5900/9024
2019-09-16T22:27:34.6472028Z .................................................................................................... 6000/9024
2019-09-16T22:27:34.6472028Z .................................................................................................... 6000/9024
2019-09-16T22:27:40.6518556Z .........................................................................................i..ii...... 6100/9024
2019-09-16T22:28:08.3858221Z .................................................................................................... 6300/9024
2019-09-16T22:28:12.4915633Z ................................................i................................................... 6400/9024
2019-09-16T22:28:14.6487720Z .................................................................................................... 6500/9024
2019-09-16T22:28:17.1084103Z ....................i............................................................................... 6600/9024
---
2019-09-16T22:32:10.3633065Z 
2019-09-16T22:32:10.3633498Z ---- [ui] ui/consts/miri_unleashed/assoc_const.rs stdout ----
2019-09-16T22:32:10.3633545Z diff of stderr:
2019-09-16T22:32:10.3633634Z 
2019-09-16T22:32:10.3633672Z 4 LL |     const F: u32 = (U::X, 42).1;
2019-09-16T22:32:10.3633743Z 6 
2019-09-16T22:32:10.3633953Z - warning: skipping const checks
2019-09-16T22:32:10.3634665Z -   --> $DIR/assoc_const.rs:19:25
2019-09-16T22:32:10.3634854Z -    |
2019-09-16T22:32:10.3634854Z -    |
2019-09-16T22:32:10.3635092Z - LL |     const X: Vec<u32> = Vec::new();
2019-09-16T22:32:10.3635502Z - 
2019-09-16T22:32:10.3635577Z 13 error[E0080]: erroneous constant used
2019-09-16T22:32:10.3635792Z 14   --> $DIR/assoc_const.rs:29:13
2019-09-16T22:32:10.3635839Z 15    |
2019-09-16T22:32:10.3635839Z 15    |
2019-09-16T22:32:10.3635867Z 
2019-09-16T22:32:10.3635911Z 
2019-09-16T22:32:10.3635957Z The actual stderr differed from the expected stderr.
2019-09-16T22:32:10.3636262Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/assoc_const/assoc_const.stderr
2019-09-16T22:32:10.3636505Z To update references, rerun the tests and pass the `--bless` flag
2019-09-16T22:32:10.3636789Z To only update this specific test, also pass `--test-args consts/miri_unleashed/assoc_const.rs`
2019-09-16T22:32:10.3636869Z error: 1 errors occurred comparing output.
2019-09-16T22:32:10.3636932Z status: exit code: 1
2019-09-16T22:32:10.3636932Z status: exit code: 1
2019-09-16T22:32:10.3638043Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/miri_unleashed/assoc_const.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/consts/miri_unleashed/assoc_const" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zunleash-the-miri-inside-of-you" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/assoc_const/auxiliary" "-A" "unused"
2019-09-16T22:32:10.3638550Z ------------------------------------------
2019-09-16T22:32:10.3638583Z 
2019-09-16T22:32:10.3638790Z ------------------------------------------
2019-09-16T22:32:10.3638832Z stderr:
2019-09-16T22:32:10.3638832Z stderr:
2019-09-16T22:32:10.3639181Z ------------------------------------------
2019-09-16T22:32:10.3639401Z warning: skipping const checks
2019-09-16T22:32:10.3639607Z   --> /checkout/src/test/ui/consts/miri_unleashed/assoc_const.rs:12:20
2019-09-16T22:32:10.3639651Z    |
2019-09-16T22:32:10.3639710Z LL |     const F: u32 = (U::X, 42).1; //~ WARN skipping const checks
2019-09-16T22:32:10.3639793Z 
2019-09-16T22:32:10.3639829Z error[E0080]: erroneous constant used
2019-09-16T22:32:10.3640061Z   --> /checkout/src/test/ui/consts/miri_unleashed/assoc_const.rs:29:13
2019-09-16T22:32:10.3640101Z    |
2019-09-16T22:32:10.3640101Z    |
2019-09-16T22:32:10.3640144Z LL |     let y = <String as Bar<Vec<u32>, String>>::F; //~ ERROR erroneous constant
2019-09-16T22:32:10.3640208Z    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
2019-09-16T22:32:10.3640272Z error: aborting due to previous error
2019-09-16T22:32:10.3640297Z 
2019-09-16T22:32:10.3640513Z For more information about this error, try `rustc --explain E0080`.
2019-09-16T22:32:10.3640542Z 
---
2019-09-16T22:32:10.3641432Z 
2019-09-16T22:32:10.3641484Z 1 warning: skipping const checks
2019-09-16T22:32:10.3641692Z +   --> $DIR/mutable_const.rs:9:38
2019-09-16T22:32:10.3641730Z +    |
2019-09-16T22:32:10.3641770Z + LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
2019-09-16T22:32:10.3641868Z + 
2019-09-16T22:32:10.3641902Z + warning: skipping const checks
2019-09-16T22:32:10.3642251Z 2   --> $DIR/mutable_const.rs:14:9
2019-09-16T22:32:10.3642288Z 3    |
2019-09-16T22:32:10.3642288Z 3    |
2019-09-16T22:32:10.3642323Z 4 LL |         *MUTABLE_BEHIND_RAW = 99
2019-09-16T22:32:10.3642382Z 
2019-09-16T22:32:10.3642418Z The actual stderr differed from the expected stderr.
2019-09-16T22:32:10.3642835Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/mutable_const/mutable_const.stderr
2019-09-16T22:32:10.3642835Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/mutable_const/mutable_const.stderr
2019-09-16T22:32:10.3643050Z To update references, rerun the tests and pass the `--bless` flag
2019-09-16T22:32:10.3643443Z To only update this specific test, also pass `--test-args consts/miri_unleashed/mutable_const.rs`
2019-09-16T22:32:10.3643523Z error: 1 errors occurred comparing output.
2019-09-16T22:32:10.3643559Z status: exit code: 1
2019-09-16T22:32:10.3643559Z status: exit code: 1
2019-09-16T22:32:10.3644706Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/miri_unleashed/mutable_const.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/consts/miri_unleashed/mutable_const" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zunleash-the-miri-inside-of-you" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/mutable_const/auxiliary" "-A" "unused"
2019-09-16T22:32:10.3645072Z ------------------------------------------
2019-09-16T22:32:10.3645121Z 
2019-09-16T22:32:10.3645335Z ------------------------------------------
2019-09-16T22:32:10.3645379Z stderr:
2019-09-16T22:32:10.3645379Z stderr:
2019-09-16T22:32:10.3645587Z ------------------------------------------
2019-09-16T22:32:10.3645651Z warning: skipping const checks
2019-09-16T22:32:10.3645896Z   --> /checkout/src/test/ui/consts/miri_unleashed/mutable_const.rs:9:38
2019-09-16T22:32:10.3645946Z    |
2019-09-16T22:32:10.3646016Z LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
2019-09-16T22:32:10.3646101Z 
2019-09-16T22:32:10.3646162Z warning: skipping const checks
2019-09-16T22:32:10.3646406Z   --> /checkout/src/test/ui/consts/miri_unleashed/mutable_const.rs:14:9
2019-09-16T22:32:10.3646452Z    |
2019-09-16T22:32:10.3646452Z    |
2019-09-16T22:32:10.3646516Z LL |         *MUTABLE_BEHIND_RAW = 99 //~ WARN skipping const checks
2019-09-16T22:32:10.3646614Z 
2019-09-16T22:32:10.3646658Z error: any use of this value will cause an error
2019-09-16T22:32:10.3646925Z   --> /checkout/src/test/ui/consts/miri_unleashed/mutable_const.rs:14:9
2019-09-16T22:32:10.3646973Z    |
2019-09-16T22:32:10.3646973Z    |
2019-09-16T22:32:10.3647019Z LL | / const MUTATING_BEHIND_RAW: () = {
2019-09-16T22:32:10.3647087Z LL | |     // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
2019-09-16T22:32:10.3647140Z LL | |     unsafe {
2019-09-16T22:32:10.3647191Z LL | |         *MUTABLE_BEHIND_RAW = 99 //~ WARN skipping const checks
2019-09-16T22:32:10.3647261Z    | |         ^^^^^^^^^^^^^^^^^^^^^^^^ tried to modify constant memory
2019-09-16T22:32:10.3647347Z LL | |     }
2019-09-16T22:32:10.3647390Z LL | | };
2019-09-16T22:32:10.3647743Z    | |__-
2019-09-16T22:32:10.3647777Z    |
---
2019-09-16T22:32:10.3667813Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:536:22
2019-09-16T22:32:10.3667913Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-09-16T22:32:10.3683497Z 
2019-09-16T22:32:10.3691009Z 
2019-09-16T22:32:10.3693097Z 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 -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" "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"
2019-09-16T22:32:10.3693345Z 
2019-09-16T22:32:10.3701088Z 
2019-09-16T22:32:10.3701181Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-16T22:32:10.3701225Z Build completed unsuccessfully in 1:04:07
2019-09-16T22:32:10.3701225Z Build completed unsuccessfully in 1:04:07
2019-09-16T22:32:10.3755889Z == clock drift check ==
2019-09-16T22:32:10.3771931Z   local time: Mon Sep 16 22:32:10 UTC 2019
2019-09-16T22:32:10.4648778Z   network time: Mon, 16 Sep 2019 22:32:10 GMT
2019-09-16T22:32:10.4649569Z == end clock drift check ==
2019-09-16T22:32:11.3285773Z ##[error]Bash exited with code '1'.
2019-09-16T22:32:11.3322751Z ##[section]Starting: Checkout
2019-09-16T22:32:11.3324980Z ==============================================================================
2019-09-16T22:32:11.3325058Z Task         : Get sources
2019-09-16T22:32:11.3325108Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from 3400462 to abd2034 Sep 16, 2019
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Sep 17, 2019

The job x86_64-gnu-llvm-6.0 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.
2019-09-16T23:44:01.8214835Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-16T23:44:01.8403234Z ##[command]git config gc.auto 0
2019-09-16T23:44:01.8492316Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-16T23:44:01.8550018Z ##[command]git config --get-all http.proxy
2019-09-16T23:44:01.8701692Z ##[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/64470/merge:refs/remotes/pull/64470/merge
---
2019-09-16T23:51:01.2745171Z    Compiling serde_json v1.0.40
2019-09-16T23:51:03.1496777Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-09-16T23:51:13.9276232Z     Finished release [optimized] target(s) in 1m 29s
2019-09-16T23:51:13.9375183Z tidy check
2019-09-16T23:51:14.5677693Z tidy error: /checkout/src/test/ui/consts/miri_unleashed/feature-gate-unleash_the_miri_inside_of_you.rs:19: line longer than 100 chars
2019-09-16T23:51:15.8316048Z some tidy checks failed
2019-09-16T23:51:15.8316829Z 
2019-09-16T23:51:15.8316829Z 
2019-09-16T23:51:15.8317963Z 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"
2019-09-16T23:51:15.8318710Z 
2019-09-16T23:51:15.8318876Z 
2019-09-16T23:51:15.8324228Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-09-16T23:51:15.8324599Z Build completed unsuccessfully in 0:01:32
2019-09-16T23:51:15.8324599Z Build completed unsuccessfully in 0:01:32
2019-09-16T23:51:15.8373866Z == clock drift check ==
2019-09-16T23:51:15.8387023Z   local time: Mon Sep 16 23:51:15 UTC 2019
2019-09-16T23:51:15.9874031Z   network time: Mon, 16 Sep 2019 23:51:15 GMT
2019-09-16T23:51:15.9876244Z == end clock drift check ==
2019-09-16T23:51:17.2706491Z ##[error]Bash exited with code '1'.
2019-09-16T23:51:17.2740107Z ##[section]Starting: Checkout
2019-09-16T23:51:17.2742775Z ==============================================================================
2019-09-16T23:51:17.2742837Z Task         : Get sources
2019-09-16T23:51:17.2742907Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from abd2034 to 5e93494 Sep 17, 2019
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Sep 17, 2019

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.
2019-09-17T00:23:31.0456700Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-17T00:23:31.0655056Z ##[command]git config gc.auto 0
2019-09-17T00:23:31.0740488Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-17T00:23:31.0796593Z ##[command]git config --get-all http.proxy
2019-09-17T00:23:31.0945867Z ##[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/64470/merge:refs/remotes/pull/64470/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)

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from 5e93494 to fe0d220 Sep 17, 2019
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Sep 17, 2019

The job x86_64-gnu-llvm-6.0 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.
2019-09-17T01:36:09.4724272Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-17T01:36:09.5015113Z ##[command]git config gc.auto 0
2019-09-17T01:36:09.5063813Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-17T01:36:09.5123552Z ##[command]git config --get-all http.proxy
2019-09-17T01:36:09.5298115Z ##[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/64470/merge:refs/remotes/pull/64470/merge
---
2019-09-17T02:49:08.5704184Z .................................................................................................... 1500/9024
2019-09-17T02:49:15.4221683Z ...................................................................................F................ 1600/9024
2019-09-17T02:49:29.7757919Z .................................................................i...............i.................. 1700/9024
2019-09-17T02:49:37.8901694Z .................................................................................................... 1800/9024
2019-09-17T02:49:55.1396321Z ........................................................iiiii....................................... 1900/9024
2019-09-17T02:50:08.6273263Z .................................................................................................... 2100/9024
2019-09-17T02:50:11.4843041Z .................................................................................................... 2200/9024
2019-09-17T02:50:15.3260808Z .................................................................................................... 2300/9024
2019-09-17T02:50:24.9061934Z .................................................................................................... 2400/9024
---
2019-09-17T02:53:45.9019407Z ............................................i...............i....................................... 4700/9024
2019-09-17T02:53:57.5321878Z .................................................................................................... 4800/9024
2019-09-17T02:54:05.6970318Z .................................................................................................... 4900/9024
2019-09-17T02:54:16.7994555Z .................................................................................................... 5000/9024
2019-09-17T02:54:25.6089402Z ............................ii.ii................................................................... 5100/9024
2019-09-17T02:54:36.8679194Z .................................................................................................... 5300/9024
2019-09-17T02:54:48.6514370Z ............................................................................................i....... 5400/9024
2019-09-17T02:54:58.0068501Z .................................................................................................... 5500/9024
2019-09-17T02:55:03.4067765Z .................................................................................................... 5600/9024
2019-09-17T02:55:03.4067765Z .................................................................................................... 5600/9024
2019-09-17T02:55:15.4786728Z .......................................................................................ii...i..ii... 5700/9024
2019-09-17T02:55:44.5953471Z .................................................................................................... 5900/9024
2019-09-17T02:55:56.2376336Z .................................................................................................... 6000/9024
2019-09-17T02:55:56.2376336Z .................................................................................................... 6000/9024
2019-09-17T02:56:06.3440368Z .........................................................................................i..ii...... 6100/9024
2019-09-17T02:56:41.4256817Z .................................................................................................... 6300/9024
2019-09-17T02:56:46.4854283Z ................................................i................................................... 6400/9024
2019-09-17T02:56:49.0434085Z .................................................................................................... 6500/9024
2019-09-17T02:56:51.9417302Z ....................i............................................................................... 6600/9024
---
2019-09-17T03:01:36.3434683Z 
2019-09-17T03:01:36.3434826Z 7 warning: skipping const checks
2019-09-17T03:01:36.3435901Z 8   --> $DIR/assoc_const.rs:19:25
2019-09-17T03:01:36.3436112Z 9    |
2019-09-17T03:01:36.3436476Z - LL |     const X: Vec<u32> = Vec::new();
2019-09-17T03:01:36.3436879Z -    |                         ^^^^^^^^^^
2019-09-17T03:01:36.3437466Z + LL |     const X: Vec<u32> = vec![1];
2019-09-17T03:01:36.3437934Z +    |
2019-09-17T03:01:36.3438512Z +    = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2019-09-17T03:01:36.3439494Z 12 
2019-09-17T03:01:36.3439558Z 13 warning: skipping const checks
---
2019-09-17T03:01:36.3440340Z 29 error[E0080]: erroneous constant used
2019-09-17T03:01:36.3440604Z -   --> $DIR/assoc_const.rs:31:13
2019-09-17T03:01:36.3440812Z +   --> $DIR/assoc_const.rs:32:13
2019-09-17T03:01:36.3440856Z 31    |
2019-09-17T03:01:36.3441009Z 32 LL |     let y = <String as Bar<Vec<u32>, String>>::F;
2019-09-17T03:01:36.3441061Z 33    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
2019-09-17T03:01:36.3441139Z 
2019-09-17T03:01:36.3441186Z The actual stderr differed from the expected stderr.
2019-09-17T03:01:36.3441714Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/assoc_const/assoc_const.stderr
2019-09-17T03:01:36.3441714Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/assoc_const/assoc_const.stderr
2019-09-17T03:01:36.3442071Z To update references, rerun the tests and pass the `--bless` flag
2019-09-17T03:01:36.3442391Z To only update this specific test, also pass `--test-args consts/miri_unleashed/assoc_const.rs`
2019-09-17T03:01:36.3442477Z error: 1 errors occurred comparing output.
2019-09-17T03:01:36.3443006Z status: exit code: 1
2019-09-17T03:01:36.3443006Z status: exit code: 1
2019-09-17T03:01:36.3443882Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/miri_unleashed/assoc_const.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/consts/miri_unleashed/assoc_const" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zunleash-the-miri-inside-of-you" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/miri_unleashed/assoc_const/auxiliary" "-A" "unused"
2019-09-17T03:01:36.3444418Z ------------------------------------------
2019-09-17T03:01:36.3444452Z 
2019-09-17T03:01:36.3444680Z ------------------------------------------
2019-09-17T03:01:36.3444726Z stderr:
2019-09-17T03:01:36.3444726Z stderr:
2019-09-17T03:01:36.3444932Z ------------------------------------------
2019-09-17T03:01:36.3444995Z warning: skipping const checks
2019-09-17T03:01:36.3445247Z   --> /checkout/src/test/ui/consts/miri_unleashed/assoc_const.rs:12:20
2019-09-17T03:01:36.3445297Z    |
2019-09-17T03:01:36.3445363Z LL |     const F: u32 = (U::X, 42).1; //~ WARN skipping const checks
2019-09-17T03:01:36.3445440Z 
2019-09-17T03:01:36.3445482Z warning: skipping const checks
2019-09-17T03:01:36.3445746Z   --> /checkout/src/test/ui/consts/miri_unleashed/assoc_const.rs:19:25
2019-09-17T03:01:36.3445793Z    |
2019-09-17T03:01:36.3445793Z    |
2019-09-17T03:01:36.3445846Z LL |     const X: Vec<u32> = vec![1];
2019-09-17T03:01:36.3445960Z    |
2019-09-17T03:01:36.3446276Z    = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2019-09-17T03:01:36.3446318Z 
2019-09-17T03:01:36.3446385Z warning: skipping const checks
2019-09-17T03:01:36.3446385Z warning: skipping const checks
2019-09-17T03:01:36.3446630Z   --> /checkout/src/test/ui/consts/miri_unleashed/assoc_const.rs:19:25
2019-09-17T03:01:36.3446678Z    |
2019-09-17T03:01:36.3446737Z LL |     const X: Vec<u32> = vec![1];
2019-09-17T03:01:36.3446822Z    |
2019-09-17T03:01:36.3447151Z    = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2019-09-17T03:01:36.3447192Z 
2019-09-17T03:01:36.3447234Z warning: skipping const checks
2019-09-17T03:01:36.3447234Z warning: skipping const checks
2019-09-17T03:01:36.3447484Z   --> /checkout/src/test/ui/consts/miri_unleashed/assoc_const.rs:19:25
2019-09-17T03:01:36.3447555Z    |
2019-09-17T03:01:36.3447596Z LL |     const X: Vec<u32> = vec![1];
2019-09-17T03:01:36.3447701Z    |
2019-09-17T03:01:36.3448012Z    = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2019-09-17T03:01:36.3448051Z 
2019-09-17T03:01:36.3448111Z error[E0080]: erroneous constant used
2019-09-17T03:01:36.3448111Z error[E0080]: erroneous constant used
2019-09-17T03:01:36.3448353Z   --> /checkout/src/test/ui/consts/miri_unleashed/assoc_const.rs:32:13
2019-09-17T03:01:36.3448399Z    |
2019-09-17T03:01:36.3448448Z LL |     let y = <String as Bar<Vec<u32>, String>>::F; //~ ERROR erroneous constant
2019-09-17T03:01:36.3448519Z    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
2019-09-17T03:01:36.3448594Z error: aborting due to previous error
2019-09-17T03:01:36.3448622Z 
2019-09-17T03:01:36.3448970Z For more information about this error, try `rustc --explain E0080`.
2019-09-17T03:01:36.3449021Z 
---
2019-09-17T03:01:36.3476061Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:536:22
2019-09-17T03:01:36.3476189Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-09-17T03:01:36.3488378Z 
2019-09-17T03:01:36.3488469Z 
2019-09-17T03:01:36.3499823Z 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 -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" "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"
2019-09-17T03:01:36.3500317Z 
2019-09-17T03:01:36.3500488Z 
2019-09-17T03:01:37.2685050Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-17T03:01:37.2694154Z Build completed unsuccessfully in 1:17:00
2019-09-17T03:01:37.2694154Z Build completed unsuccessfully in 1:17:00
2019-09-17T03:01:37.2694728Z == clock drift check ==
2019-09-17T03:01:37.2694916Z   local time: Tue Sep 17 03:01:36 UTC 2019
2019-09-17T03:01:37.2695105Z   network time: Tue, 17 Sep 2019 03:01:36 GMT
2019-09-17T03:01:37.2695251Z == end clock drift check ==
2019-09-17T03:01:37.4667926Z ##[error]Bash exited with code '1'.
2019-09-17T03:01:37.4706752Z ##[section]Starting: Checkout
2019-09-17T03:01:37.4708895Z ==============================================================================
2019-09-17T03:01:37.4708951Z Task         : Get sources
2019-09-17T03:01:37.4709035Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch 3 times, most recently from 3b1e7e5 to 0e431ee Sep 17, 2019
@ecstatic-morse

This comment has been minimized.

Copy link
Contributor Author

commented Sep 17, 2019

I've cleaned up the history a bit, and I'm happy with the current state of this. I'm removing the draft status, although there's a few decisions that need to be made before this is actually merged.

This PR now allows validation to proceed in two modes, controlled by use_new_validator. If that flag is false, the old validator is responsible for actually emitting the errors, but the new validator still runs so it can compare the errors it would have emitted. Currently, if the errors don't match, the PR panics to trigger test failures.

If use_new_validator is set, we suppress all errors in the old validator and simply run the new one. No comparison is done because I expect this flag to only be set for items where dataflow is actually required, at least until we can remove the old pass entirely. The old pass is still run unconditionally because it does promotability analysis as well.

Also, -Zunleash-the-miri-inside-you turns on the new validator. This not strictly necessary, but the new validator gives better warnings about when a const check is ignored.

cc @oli-obk @eddyb This is designed to be reviewed commit-by-commit which should make things a bit more manageable.

@ecstatic-morse ecstatic-morse marked this pull request as ready for review Sep 17, 2019
@ecstatic-morse ecstatic-morse changed the title Split const validation from promotion Implement dataflow-based const validation Sep 17, 2019
We relied previously on the caller (e.g. `Q::in_operand`) to ignore
`Local`s that were indirectly mutable (and thus assumed to be
qualified). However, it's much clearer (and more efficient) to do this
in the resolver itself.

This does not yet remove the masking done in `Q::in_operand` and others
for safety's sake, although I believe that should now be possible.
Picks up changes made in #64513
@ecstatic-morse ecstatic-morse force-pushed the ecstatic-morse:split-promotion-and-validation branch from 4041746 to 0bf1a80 Sep 28, 2019
@ecstatic-morse

This comment has been minimized.

Copy link
Contributor Author

commented Sep 28, 2019

I had to rebase on the latest master to pick up the changes in #64513.

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Sep 28, 2019

@bors r=eddyb,oli-obk

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 28, 2019

📌 Commit 0bf1a80 has been approved by eddyb,oli-obk

@Centril

This comment has been minimized.

Copy link
Member

commented Sep 28, 2019

@bors p=4

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2019

⌛️ Testing commit 0bf1a80 with merge 0bbab7d...

bors added a commit that referenced this pull request Sep 29, 2019
… r=eddyb,oli-obk

Implement dataflow-based const validation

This PR adds a separate, dataflow-enabled pass that checks the bodies of `const`s, `static`s and `const fn`s for [const safety](https://github.com/rust-rfcs/const-eval/blob/master/const.md). This is based on my work in #63860, which tried to integrate into the existing pass in [`qualify_consts.rs`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs). However, the resulting pass was even more unwieldy than the original. Unlike its predecessor, this PR is designed to be combined with #63812 to replace the existing pass completely.

The new checker lives in [`librustc_mir/transform/check_consts`](https://github.com/ecstatic-morse/rust/tree/split-promotion-and-validation/src/librustc_mir/transform/check_consts).

[`qualifs.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/qualifs.rs) contains small modifications to the existing `Qualif` trait and its implementors, but is mostly unchanged except for the removal of `IsNotPromotable` and `IsNotImplicitlyPromotable`, which are only necessary for promotion.

[`resolver.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/resolver.rs) contains the dataflow analysis used to propagate qualifs between locals.

Finally, [`validation.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/validation.rs) contains a refactored version of the existing [`Visitor`](https://github.com/rust-lang/rust/blob/ca3766e2e58f462a20922e42c821a37eaf0e13db/src/librustc_mir/transform/qualify_consts.rs#L1024) in `qualfy_consts.rs`. All errors have been associated with a `struct` to make [comparison with the existing pass](https://github.com/ecstatic-morse/rust/blob/1c19f2d540ca0a964900449d79a5d5181b43146d/src/librustc_mir/transform/qualify_consts.rs#L1006) simple.

The existing validation logic in [`qualify_consts`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs) has been modified to allow it to run in parallel with the new validator. If [`use_new_validator`](https://github.com/rust-lang/rust/pull/64470/files#diff-c2552a106550d05b69d5e07612f0f812R950) is not set, the old validation will be responsible for actually generating the errors, but those errors can be compared with the ones from the new validator.
@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2019

☀️ Test successful - checks-azure
Approved by: eddyb,oli-obk
Pushing 0bbab7d to master...

@bors bors added the merged-by-bors label Sep 29, 2019
@bors bors merged commit 0bf1a80 into rust-lang:master Sep 29, 2019
5 checks passed
5 checks passed
homu Test successful
Details
pr Build #20190928.44 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
@andjo403

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2019

this PR cause large perf regression see perf
the query check_match seems to have the biggest impact
but also mir_validated

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2019

This is expected since we're running old and new and comparing the result. When we remove the old check we should get perf back

@ecstatic-morse

This comment has been minimized.

Copy link
Contributor Author

commented Sep 29, 2019

Why would this PR affect check_match (the HIR check that validates patterns in match arms)?

Centril added a commit to Centril/rust that referenced this pull request Oct 2, 2019
…=oli-obk

Enable support for `IndirectlyMutableLocals` in `rustc_peek`

This PR allows `rustc_peek` tests to be written for the `IndirectlyMutableLocals` analysis implemented in rust-lang#64470. See any of the tests in [`test/ui/mir-dataflow`](https://github.com/rust-lang/rust/blob/master/src/test/ui/mir-dataflow/inits-1.rs) for an example.

Included in this PR is a major rewrite of the `rustc_peek` module. This was motivated by the differences between the `IndirectlyMutableLocals` analysis and the initialized places ones.

To properly test `IndirectlyMutableLocals`, we must pass locals by-value to `rustc_peek`, since any local that is not `Freeze` will be marked as indirectly mutable as soon as a reference to it is taken. Unfortunately, `UnsafeCell` is not `Copy`, so we can only do one `rustc_peek` on each value with interior mutability inside a test. I'm not sure how to deal with this restriction; perhaps I need to special case borrows preceding a call to `rustc_peek` in the analysis itself?

`rustc_peek` also assumed that the analysis was done on move paths and that its transfer function only needed to be applied at assignment statements. This PR removes both of those restrictions by adding a trait, `RustcPeekAt`, that controls how the peeked at `Place` maps to the current dataflow state and using a dataflow cursor to retrieve the state itself.

Finally, this PR adds a test which demonstrates some unsoundness in the `IndirectlyMutableLocals` analysis by converting a reference to a `Freeze` field to a reference to a `!Freeze` field by offsetting a pointer (or in this case transmuting a pointer to a ZST field with the same address as a `!Freeze` field). This does not represent a hole in the language proper, since this analysis is only used to validate `const` bodies, in which the unsound code will only compile with `-Zunleash-the-miri-inside-of-you`. Nevertheless, this should get fixed.

r? @oli-obk
@joshlf

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2019

I assume somebody has checked, but just in case not: does this affect the static_assertions crate, which relies on const evaluation to fail in some cases?

(cc @nvzqz )

@nvzqz

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2019

It currently expects const eval for array size overflow to fail. But even if that changes to allow an overflow, there’d still be a type mismatch.

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2019

Any stable behaviour won't be changed by anything we implement. The only thing that happens is that unstable behaviour or unimplemented behaviour gets stabilized. If a macro were to expand to if foo {} inside a constant, that would indeed fail right now and work later, but that's just like expanding to garlbladadf and hoping it fails to compile because that name doesn't exist.

The behaviour that the static_assertions crate depends on is either type resolution failures or things that would panic if they were runtime code. If your code panics at runtime and you move it to compile time, you get a compile time error, guaranteed.

@nvzqz

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2019

Once const in if is stabilized, I think the initial approach would be to emit (via build.rs) a const_assert! that has a different body depending on whether the used Rust compiler version supports the feature. This would allow for having a meaningful error message via panic!. This would not be a breaking change since it doesn't bump the minimum required Rust version.

However, once const_assert! starts allowing for custom formatted error messages, then that would be a breaking change and require a major version bump. Reason being that you wouldn't want one of your dependencies to start using const_assert!(CONDITION, "Assumption X failed") and that breaking your builds. If not by then, down the line once const string formatting works, you'd also be able to do const_assert!(X > Y, "{} > {} failed", X, Y). If that isn't available in the same version in which const in if is stabilized, then that's yet another breaking change.

I'm totally fine with breaking changes in static_assertions because it doesn't expose any types and thus won't cause incompatibility issues in the ecosystem. I think this crate is part of a small subset of the ecosystem for which that is the case.

nikomatsakis added a commit to nikomatsakis/team that referenced this pull request Oct 17, 2019
They're working to make compile-time evaluation more expressive by
enabling `if`, `match` and other control flow in constants. As one of
their first major contributions, they implemented a dataflow analysis
to validate the bodies of `const`s and `const
fn`s (rust-lang/rust#64470).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.