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 the new-style trait solver #56384

Merged
merged 19 commits into from Dec 27, 2018

Conversation

Projects
None yet
5 participants
@scalexm
Copy link
Member

scalexm commented Nov 30, 2018

Final PR of what I believe to be a minimally working implementation of the new-style trait solver.

The new trait solver can be used by providing the -Z chalk command line flag. It is currently used everywhere in rustc_typeck, and for everything relying on rustc::infer::canonical::query_response::enter_canonical_trait_query.

The trait solver is invoked in rustc by using the evaluate_goal canonical query. This is not optimal because each call to evaluate_goal creates a new chalk_engine::Forest, hence rustc cannot use answers to intermediate goals produced by the root goal. We'll need to change that but I guess that's ok for now.

Some next steps, I think, are:

  • handle region constraints: region constraints are computed but are completely ignored for now, I think we may need additional support from chalk_engine (as a side effect, types or trait references with outlive requirements cannot be proved well-formed)
  • deactivate eager normalization in the presence of -Z chalk in order to leverage the lazy normalization strategy of the new-style trait solver
  • add the remaining built-in impls (only Sized is supported currently)
  • transition the compiler to using generic goals instead of predicates that still refer to named type parameters etc

I added a few very simple tests to check that the new solver has the right behavior, they won't be needed anymore once it is mature enough. Additionally it shows off that we get implied bounds for free.

r? @nikomatsakis

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Nov 30, 2018

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:2c3d9600:start=1543604043754178478,finish=1543604101565207354,duration=57811028876
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:48:58] .................................................................................................... 300/5104
[00:49:00] .................................................................................................... 400/5104
[00:49:04] .................................................................................................... 500/5104
[00:49:07] ..............................i..................................................................... 600/5104
[00:49:10] ................................................F.F....F...............................F............ 700/5104
[00:49:16] .......F.F...............................F.........F.............................................i.. 800/5104
[00:49:24] ....................iiiii........................................................................... 1000/5104
[00:49:26] .................................................................................................... 1100/5104
[00:49:28] .................................................................................................... 1200/5104
[00:49:31] .................................................................................................... 1300/5104
---
[00:51:35] diff of stderr:
[00:51:35] 
[00:51:35] 13    |         ^^^^^^^^^
[00:51:35] 14 
[00:51:35] 15 error: any use of this value will cause an error
[00:51:35] +   --> $DIR/const-err-multi.rs:13:1
[00:51:35] +    |
[00:51:35] + LL | pub const A: i8 = -std::i8::MIN;
[00:51:35] +    |                   |
[00:51:35] +    |                   attempt to negate with overflow
[00:51:35] + 
[00:51:35] + 
[00:51:35] + error: any use of this value will cause an error
[00:51:35] 17    |
[00:51:35] 17    |
[00:51:35] 18 LL | pub const B: i8 = A;
[00:51:35] 36    |                   |
[00:51:35] 37    |                   referenced constant has errors
[00:51:35] 38 
[00:51:35] - error: aborting due to 4 previous errors
[00:51:35] - error: aborting due to 4 previous errors
[00:51:35] + error: aborting due to 5 previous errors
[00:51:35] 40 
[00:51:35] 41 
[00:51:35] 
[00:51:35] 
[00:51:35] The actual stderr differed from the expected stderr.
[00:51:35] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-err-multi/const-err-multi.stderr
[00:51:35] To update references, rerun the tests and pass the `--bless` flag
[00:51:35] To only update this specific test, also pass `--test-args consts/const-err-multi.rs`
[00:51:35] error: 1 errors occurred comparing output.
[00:51:35] status: exit code: 1
[00:51:35] status: exit code: 1
[00:51:35] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "ile_name":"/checkout/src/test/ui/consts/const-err-multi.rs","byte_start":475,"byte_end":484,"line_start":11,"line_end":11,"column_start":9,"column_end":18,"is_primary":true,"text":[{"text":"#![deny(const_err)]","highlight_start":9,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-err-multi.rs:13:1\n   |\nLL | pub const A: i8 = -std::i8::MIN;\n   | ^^^^^^^^^^^^^^^^^^-------------^\n   |                   |\n   |                   attempt to negate with overflow\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/consts/const-err-multi.rs:11:9\n   |\nLL | #![deny(const_err)]\n   |         ^^^^^^^^^\n\n"}
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-err-multi.rs","byte_start":506,"byte_end":519,"line_start":13,"line_end":13,"column_start":19,"column_end":32,"is_primary":false,"text":[{"text":"pub const A: i8 = -std::i8::MIN;","highlight_start":19,"highlight_end":32}],"label":"attempt to negate with overflow","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-err-multi.rs","byte_start":488,"byte_end":520,"line_start":13,"line_end":13,"column_start":1,"column_end":33,"is_primary":true,"text":[{"text":"pub const A: i8 = -std::i8::MIN;","highlight_start":1,"highlight_end":33}],"label":null,"suggested_replaces":[{"file_name":"/checkout/src/test/ui/consts/const-err-multi.rs","byte_start":602,"byte_end":609,"line_start":17,"line_end":17,"column_start":19,"column_end":26,"is_primary":false,"text":[{"text":"pub const C: u8 = A as u8;","highlight_start":19,"highlight_end":26}],"label":"referenced constant has errors","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-err-multi.rs","byte_start":584,"byte_end":610,"line_start":17,"line_end":17,"column_start":1,"column_end":27,"is_primary":true,"text":[{"text":"pub const C: u8 = A as u8;","highlight_start":1,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-err-multi.rs:17:1\n   |\nLL | pub const C: u8 = A as u8;\n   | ^^^^^^^^^^^^^^^^^^-------^\n   |                   |\n   |                   referenced constant has errors\n\n"}
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-err-multi.rs","byte_start":650,"byte_end":656,"line_start":19,"line_end":19,"column_start":19,"column_end":25,"is_primary":false,"text":[{"text":"pub const D: i8 = 50 - A;","highlight_start":19,"highlight_end":25}],"label":"referenced constant has errors","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-err-multi.rs","byte_start":632,"byte_end":617,"highlight_end":25}],"label":"index out of bounds: the len is 1 but the index is 1","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-err.rs","byte_start":613,"byte_end":638,"line_start":20,"line_end":20,"column_start":1,"column_end":26,"is_primary":true,"text":[{"text":"const FOO: u8 = [5u8][1];","highlight_start":1,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/consts/const-err.rs","byte_start":552,"byte_end":561,"line_start":14,"line_end":14,"column_start":9,"column_end":18,"is_primary":true,"text":[{"text":"#![warn(const_err)]","highlight_start":9,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"warning: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-err.rs:20:1\n   |\nLL | const FOO: u8 = [5u8][1];\n   | ^^^^^^^^^^^^^^^^--------^\n   |                 |\n   |                 index out of bounds: the len is 1 but the index is 1\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/consts/const-err.rs:14:9\n   |\nLL | #![warn(const_err)]\n   |         ^^^^^^^^^\n\n"}
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/consts/const-err.rs","byte_start":629,"byte_end":637,"line_start----------------------------------------
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs","byte_start":542,"byte_end":547,"line_start":15,"line_end":15,"column_start":19,"column_end":24,"is_primary":false,"text":[{"text":"const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];","highlight_start":19,"highlight_end":24}],"label":"attempt to subtract with overflow","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs","byte_start":524,"byte_end":574,"line_start":15,"line_end":15,"column_start":1,"column_end":51,"is_primary":true,"text":[{"text":"const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];","highlight_start":1,"highlight_end":51}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs","byte_start":475,"byte_end":484,"line_start":11,"line_end":11,"column_start":9,"column_end":18,"is_primary":true,"text":[{"text":"#![warn(const_err)]","highlight_start":9,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"warning: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs:15:1\n   |\nLL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];\n   | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |                   |\n   |                   attempt to subtract with overflow\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs:11:9\n   |\nLL | #![warn(const_err)]\n   |         ^^^^^^^^^\n\n"}
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs","byte_start":542,"byte_end":547,"line_start":15,"line_end":15,"column_start":19,"column_end":24,"is_primary":false,"text":[{"text":"const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];","highlight_start":19,"highlight_end":24}],"label":"attempt to subtract with overflow","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs","byte_start":524,"byte_end":574,"line_start":15,"line_end":15,"column_start":1,"column_end":51,"is_primary":true,"text":[{"text":"const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];","highlight_start":1,"highlight_end":51}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs:15:1\n   |\nLL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];\n   | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |                   |\n   |                   attempt to subtract with overflow\n\n"}
[00:51:35] {"message":"evaluation of constant expression failed","code":{"code":"E0080","explanation":"\nThis error indicates that the compiler was unable to sensibly evaluate an\nconstant expression that had to be evaluated. Attempting to divide by 0\nor causing integer overflow are two ways to induce this error. For example:\n\n```compile_fail,E0080\nenum Enum {\n    X = (1 << 500),\n    Y = (1 / 0)\n}\n```\n\nEnsure that the expressions given can be evaluated as the desired integer type.\nSee the FFI section of the Reference for more information about using a custom\ninteger type:\n\nhttps://doc.rust-lang.org/reference.html#ffi-attributes\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs","byte_start":659,"byte_end":662,"line_start":19,"line_end":19,"column_start":20,"column_end":23,"is_primary":true,"text":[{"text":"    println!(\"{}\", FOO);","highlight_start":20,"highlight_end":23}],"label":"referenced constant has errors","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0080]: evaluation of constant expression failed\n  --> /checkout/src/test/ui/consts/const-eval/conditional_array_execution.rs:19:20\n   |\nLL |     println!(\"{}\", FOO);\n   |                    ^^^ referenced constant has errors\n\n"}
[00:51:35] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:35] {"message":"For more information abou_primary":true,"text":[{"text":"    const Y: u32 = foo(0-1);","highlight_start":5,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-eval/issue-43197.rs:20:5\n   |\nLL |     const Y: u32 = foo(0-1);\n   |     ^^^^^^^^^^^^^^^^^^^---^^\n   |                        |\n   |                        attempt to subtract with overflow\n\n"}
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/issue-43197.rs","byte_start":558,"byte_end":561,"line_start":18,"line_end":18,"column_start":20,"column_end":23,"is_primary":false,"text":[{"text":"    const X: u32 = 0-1;","highlight_start":20,"highlight_end":23}],"label":"attempt to subtract with overflow","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/issue-43197.rs","byte_start":543,"byte_end":562,"line_start":18,"line_end":18,"column_start":5,"column_end":24,"is_primary":true,"text":[{"text":"    const X: u32 = 0-1;","highlight_start":5,"highlight_end":24}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-eval/issue-43197.rs:18:5\n   |\nLL |     const X: u32 = 0-1;\n   |     ^^^^^^^^^^^^^^^---^\n   |                    |\n   |   ts/const-eval/pub_const_err/auxiliary" "-A" "unused"
[00:51:35] ------------------------------------------
[00:51:35] 
[00:51:35] ------------------------------------------
[00:51:35] stderr:
[00:51:35] stderr:
[00:51:35] ------------------------------------------
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/pub_const_err.rs","byte_start":547,"byte_end":552,"line_start":16,"line_end":16,"column_start":20,"column_end":25,"is_primary":false,"text":[{"text":"pub const Z: u32 = 0 - 1;","highlight_start":20,"highlight_end":25}],"label":"attempt to subtract with overflow","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/pub_const_err.rs","byte_start":528,"byte_end":553,"line_start":16,"line_end":16,"column_start":1,"column_end":26,"is_primary":true,"text":[{"text":"pub const Z: u32 = 0 - 1;","highlight_start":1,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/pub_const_err.rs","byte_start":491,"byte_end":500,"line_start":12,"line_end":12,"column_start":9,"column_end":18,"is_primary":true,"text":[{"text":"#![warn(const_err)]","highlight_start":9,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"warning: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-eval/pub_const_err.rs:16:1\n   |\nLL | pub const Z: u32 = 0 - 1;\n   | ^^^^^^^^^^^^^^^^^^^-----^\n   |                    |\n   |                    attempt to subtract with overflow\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/consts/const-eval/pub_const_err.rs:12:9\n   |\nLL | #![warn(const_err)]\n   |         ^^^^^^^^^\n\n"}
[00:51:35] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:503:22
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/pub_const_err.rs","byte_start":547,"byte_end":552,"line_start":16,"line_end":16,"column_start":20,"column_end":25,"is_primary":false,"text":[{"text":"pub const Z: u32 = 0 - 1;","highlight_start":20,"highlight_end":25}],"label":"attempt to subtract with overflow","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/pub_const_err.rs","byte_start":528,"byte_end":553,"line_start":16,"line_end":16,"column_start":1,"column_end":26,"is_primary":true,"text":[{"text":"pub const Z: u32 = 0 - 1;","highlight_start":1,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-eval/pub_const_err.rs:16:1\n   |\nLL | pub const Z: u32 = 0 - 1;\n   | ^^^^^^^^^^^^^^^^^^^-----^\n   |                    |\n   |                    attempt to subtract with overflow\n\n"}
[00:51:35] ------------------------------------------
[00:51:35] 
[00:51:35] thread '[ui] ui/consts/const-eval/pub_const_err.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:51:35] 
[00:51:35] 
[00:51:35] ---- [ui] ui/consts/const-eval/pub_const_err_bin.rs stdout ----
[00:51:35] diff of stderr:
[00:51:35] 
[00:51:35] 12 LL | #![warn(const_err)]
[00:51:35] 14 
[00:51:35] 14 
[00:51:35] + warning: any use of this value will cause an error
[00:51:35] +   --> $DIR/pub_const_err_bin.rs:14:1
[00:51:35] +    |
[00:51:35] + LL | pub const Z: u32 = 0 - 1;
[00:51:35] +    |                    |
[00:51:35] +    |                    attempt to subtract with overflow
[00:51:35] + 
[00:51:35] 15 
[00:51:35] 15 
[00:51:35] 
[00:51:35] 
[00:51:35] The actual stderr differed from the expected stderr.
[00:51:35] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-eval/pub_const_err_bin/pub_const_err_bin.stderr
[00:51:35] To update references, rerun the tests and pass the `--bless` flag
[00:51:35] To only update this specific test, also pass `--test-args consts/const-eval/pub_const_err_bin.rs`
[00:51:35] error: 1 errors occurred comparing output.
[00:51:35] status: exit code: 0
[00:51:35] status: exit code: 0
[00:51:35] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-eval/pub_const_err_bin.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-consts/const-len-underflow-separate-spans.rs","byte_start":814,"byte_end":817,"line_start":21,"line_end":21,"column_start":17,"column_end":20,"is_primary":true,"text":[{"text":"    let a: [i8; LEN] = unimplemented!();","highlight_start":17,"highlight_end":20}],"label":"referenced constant has errors","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0080]: evaluation of constant value failed\n  --> /checkout/src/test/ui/consts/const-len-underflow-separate-spans.rs:21:17\n   |\nLL |     let a: [i8; LEN] = unimplemented!();\n   |                 ^^^ referenced constant has errors\n\n"}
[00:51:35] {"message":"any use of this value will cause an error","code":{"code":"const_err","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-len-underflow-separate-spans.rs","byte_start":721,"byte_end":730,"line_start":17,"line_end":17,"column_start":20,"column_end":29,"is_primary":false,"text":[{"text":"const LEN: usize = ONE - TWO;","highlight_start":20,"highlight_end":29}],"label":"attempt to subtract with overflow","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-len-underflow-separate-spans.rs","byte_start":702,"byte_end":731,"line_start":17,"line_end":17,"column_start":1,"column_end":30,"is_primary":true,"text":[{"text":"const LEN: usize = ONE - TWO;","highlight_start":1,"highlight_end":30}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: any use of this value will cause an error\n  --> /checkout/src/test/ui/consts/const-len-underflow-separate-spans.rs:17:1\n   |\nLL | const LEN: usize = ONE - TWO;\n   | ^^^^^^^^^^^^^^^^^^^---------^\n   |                    |\n   |                    attempt to subtract with overflow\n\n"}
[00:51:35] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:51:35] {"message":"For more information about this error, try `rustc --explain E0080`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0080`.\n"}
[00:51:35] ------------------------------------------
[00:51:35] 
[00:51:35] thread '[ui] ui/consts/const-len-underflow-separate-spans.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:51:35] 
[00:51:35] 
[00:51:35] ---- [ui] ui/consts/const-size_of-cycle.rs stdout ----
[00:51:35] diff of stderr:
[00:51:35] 
[00:51:35] 10 LL |     intrinsics::size_of::<T>()
[00:51:35] 11    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:51:35] 12 note: ...which requires computing layout of `Foo`...
[00:51:35] - note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`...
[00:51:35] + note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: Some(DefId(0/0:3 ~ const_size_of_cycle[317d]::Foo[0])) }, value: [u8; _] }`...
[00:51:35] 14 note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`...
[00:51:35] 15   --> $DIR/const-size_of-c_fail,E0391\ntrait FirstTrait : SecondTrait {\n\n}\n\ntrait SecondTrait : FirstTrait {\n\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-size_of-cycle.rs","byte_start":559,"byte_end":585,"line_start":16,"line_end":16,"column_start":17,"column_end":43,"is_primary":true,"text":[{"text":"    bytes: [u8; std::mem::size_of::<Foo>()]","highlight_start":17,"highlight_end":43}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"...which requires const-evaluating `Foo::bytes::{{constant}}`...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/libcore/mem.rs","byte_start":9886,"byte_end":9912,"line_start":302,"line_end":302,"column_start":5,"column_end":31,"is_primary":true,"text":[{"text":"    intrinsics::size_of::<T>()","highlight_start":5,"highlight_end":31}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...which requires computing layout of `Foo`...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/consts/const-size_of-cycle.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"// Copyright 2017 The Rust Project Developers. See the COPYRIGHT","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: Some(DefId(0/nsion":null}],"children":[],"rendered":null}],"rendered":"error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}`\n  --> /checkout/src/test/ui/consts/const-size_of-cycle.rs:16:17\n   |\nLL |     bytes: [u8; std::mem::size_of::<Foo>()]\n   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\nnote: ...which requires const-evaluating `Foo::bytes::{{constant}}`...\n  --> /checkout/src/libcore/mem.rs:302:5\n   |\nLL |     intrinsics::size_of::<T>()\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^\nnote: ...which requires computing layout of `Foo`...\nnote: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: Some(DefId(0/0:3 ~ const_size_of_cycle[317d]::Foo[0])) }, value: [u8; _] }`...\nnote: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`...\n  --> /checkout/src/test/ui/consts/const-size_of-cycle.rs:16:17\n   |\nLL |     bytes: [u8; std::mem::size_of::<Foo>()]\n   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^\n   = note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle\nnote: cycle used when processing `Foo`\n  --> /checkout/src/test/ui/consts/const-size_of-cycle.rs:15:1\n   |\nLL | struct Foo {\n   | ^^^^^^^^^^\n\n"}
[00:51:35] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:51:35] {"message":"For more information about this error, try `rustc --explain E0391`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --eest/ui/issues/issue-44415.rs","byte_start":557,"byte_end":585,"line_start":16,"line_end":16,"column_start":26,"column_end":54,"is_primary":true,"text":[{"text":"    bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],","highlight_start":26,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...which requires computing layout of `Foo`...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-44415.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"// Copyright 2018 The Rust Project Developers. See the COPYRIGHT","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: Some(DefId(0/0:4 ~ issue_44415[317d]::Foo[0])) }, value: [u8; _] }`...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-44415.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"// Copyright 2018 The Rust Project Developers. See the COPYRIGHT","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...which requires const-evaluating + checking `Foo::bytes::{{constant}}`...","code":null,"level":"note","spa101
[00:51:35] 
[00:51:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:51:35] Build completed unsuccessfully in 0:03:55
[00:51:35] Build completed unsuccessfully in 0:03:55
[00:51:35] make: *** [check] Error 1
[00:51:35] Makefile:58: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:144d2f50
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Fri Nov 30 19:46:45 UTC 2018
---
travis_time:end:10589278:start=1543607206943754554,finish=1543607206949448796,duration=5694242
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:369e501a
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|

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)

@scalexm scalexm force-pushed the scalexm:chalk branch from 1cbf37f to eb4fa48 Nov 30, 2018

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 30, 2018

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

@scalexm scalexm force-pushed the scalexm:chalk branch from eb4fa48 to ecc8604 Nov 30, 2018

@mark-i-m

This comment has been minimized.

Copy link
Contributor

mark-i-m commented Dec 1, 2018

The title of this PR is so epic

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 8, 2018

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

@scalexm scalexm force-pushed the scalexm:chalk branch from ecc8604 to f1b0eb4 Dec 8, 2018

@nikomatsakis
Copy link
Contributor

nikomatsakis left a comment

Sorry for being so slow @scalexm -- this looks great, but I do have a few concerns:

  • We should decide how to handle subtyping before landing; a FIXME may suffice here
  • I'm a bit concerned about adding the def-id to param-env, it seems like this could affect queries in unintended ways, leading to less re-use than we would otherwise get

(Maybe we can only set the def-id if -Zchalk is used for now?)

ty::Infer(..) => {
// Everybody can find at least two types to unify against:
// general ty vars, int vars and float vars.
push_builtin_impl(tcx.types.i32, &[]);

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

Hmm, this worries me. I feel like there could be cases where chalk is able to try out all 4 of those possibilities and conclude that something is true since because it doesn't know of the other Sized impls. But I see the challenge here, of course, in that to generate the "full set of sized impls" would in some sense require iterating over all the types in the system.

(This problem, though, doesn't seem entirely unique to sized)

I wonder if we should think about tweaking how the engine walks around this case. It's probably ok to land the code as is for now, but we likely want to add some sort of FIXME issue here to revisit this question specifically.

This comment has been minimized.

@scalexm

scalexm Dec 17, 2018

Member

This is definitely a hack indeed. We need to add a FIXME yes.

This comment has been minimized.

@scalexm

scalexm Dec 17, 2018

Member

Also I believe this problem is indeed not unique to Sized, but at least it would only show for traits that have built-in impls generated by the compiler. Other traits would be fine since we would be able to enumerate all the (user-written) impls.

Show resolved Hide resolved src/librustc_traits/chalk_context/program_clauses.rs
Show resolved Hide resolved src/librustc_traits/chalk_context/mod.rs
Show resolved Hide resolved src/librustc_traits/chalk_context/mod.rs Outdated
Show resolved Hide resolved src/librustc_traits/chalk_context/mod.rs
Show resolved Hide resolved src/test/compile-fail/chalkify/chalk_initial_program.rs
Show resolved Hide resolved src/test/ui/chalkify/type_inference.rs
// `Set<T>` is an input type of `take_a_set`, hence we know that
// `T` must implement `Hash`, and we know in turn that `T` must
// implement `Eq`.
only_eq::<T>()

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

Neat.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Dec 19, 2018

Current status to my knowledge:

Waiting on @scalexm to rebase over the new version of chalk, at least, and perhaps to answer a few more of the questions above.

@scalexm scalexm force-pushed the scalexm:chalk branch from f1b0eb4 to 3926994 Dec 20, 2018

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Dec 20, 2018

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:23a44ba0:start=1545332293688084218,finish=1545332296187319194,duration=2499234976
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:56:34] .................................................................................................... 400/5192
[00:56:38] .................................................................................................... 500/5192
[00:56:41] ...............................i.................................................................... 600/5192
[00:56:44] .................................................................................................... 700/5192
[00:56:49] .....................................................F.............................................. 800/5192
[00:56:56] ...............................iiiii................................................................ 1000/5192
[00:56:59] .................................................................................................... 1100/5192
[00:57:02] .................................................................................................... 1200/5192
[00:57:04] .................................................................................................... 1300/5192
---
[00:57:35] .................................................................................................... 2300/5192
[00:57:39] .................................................................................................... 2400/5192
[00:57:42] .................................................................................................... 2500/5192
[00:57:46] .................................................................................................... 2600/5192
[00:57:50] ................F................................................................................... 2700/5192
[00:57:56] .................................................................................................... 2900/5192
[00:58:00] .................................................................................................... 3000/5192
[00:58:03] ..............................................................................................i..... 3100/5192
[00:58:06] .................................................................................................... 3200/5192
---
[00:59:01] .................................................................................................... 4800/5192
[00:59:04] .................................................................................................... 4900/5192
[00:59:07] .................................................................................................... 5000/5192
[00:59:10] .................................................................................................... 5100/5192
code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0391`.\n"}
[00:59:12] ------------------------------------------
[00:59:12] 
[00:59:12] thread '[ui] ui/consts/const-size_of-cycle.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3255:9
[00:59:12] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:59:12] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:59:12] 
[00:59:12] ---- [ui] ui/issues/issue-44415.rs stdout ----
[00:59:12] diff of stderr:
[00:59:12] 
[00:59:12] 10 LL |     bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
[00:59:12] 11    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:59:12] 12 note: ...which requires computing layout of `Foo`...
[00:59:12] - note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`...
[00:59:12] + note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: [u8; _] }`...
[00:59:12] 14 note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`...
[00:59:12] 16    |
[00:59:12] 
[00:59:12] 
[00:59:12] The actual stderr differed from the expected stderr.
[00:59:12] The actual stderr differed from the expected stderr.
[00:59:12] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-44415/issue-44415.stderr
[00:59:12] To update references, rerun the tests and pass the `--bless` flag
[00:59:12] To only update this specific test, also pass `--test-args issues/issue-44415.rs`
[00:59:12] 
[00:59:12] error: 1 errors occurred comparing ou const-evaluating + checking `Foo::bytes::{{constant}}`...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-44415.rs","byte_start":548,"byte_end":554,"line_start":16,"line_end":16,"column_start":17,"column_end":23,"is_primary":true,"text":[{"text":"    bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],","highlight_start":17,"highlight_end":23}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"cycle used when processing `Foo`","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-44415.rs","byte_start":519,"byte_end":529,"line_start":15,"line_end":15,"column_start":1,"column_end":11,"is_primary":true,"text":[{"text":"struct Foo {","highlight_start":1,"highlight_end":11}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}`\n  --> /checkout/src/test/ui/issues/issue-44415.rs:16:17\n   |\nLL |     bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],\n   |                 ^^^^^^\n   |\nnote: ...which requires const-evaluating `Foo::bytes::{{constant}}`...\n  --> /checkout/src/test/ui/issues/issue-44415.rs:16:26\n   |\nLL |     bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],\n   |                          ^^^^^^^^^^^^^^^travis_time:end:212f30f2:start=1545332304680113240,finish=1545335857401528064,duration=3552721414824
travis_time:start:050346d2
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Dec 20 19:57:37 UTC 2018
Thu, 20 Dec 2018 19:57:37 GMT

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)

@scalexm scalexm force-pushed the scalexm:chalk branch from 3926994 to 9dab10d Dec 20, 2018

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Dec 27, 2018

@bors r+

I think it's a good idea to land this so we can iterate in tree

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 27, 2018

📌 Commit 9dab10d has been approved by nikomatsakis

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 27, 2018

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout chalk (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self chalk --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
warning: Cannot merge binary files: Cargo.lock (HEAD vs. heads/homu-tmp)
Auto-merging src/test/ui/issues/issue-44415.stderr
Auto-merging src/test/ui/consts/const-size_of-cycle.stderr
Auto-merging src/librustc_typeck/check/compare_method.rs
Auto-merging src/librustc_traits/type_op.rs
Auto-merging src/librustc_traits/lowering/mod.rs
Auto-merging src/librustc_traits/lowering/environment.rs
Auto-merging src/librustc_traits/lib.rs
Auto-merging src/librustc_traits/dropck_outlives.rs
Auto-merging src/librustc_traits/chalk_context/program_clauses.rs
Auto-merging src/librustc_traits/chalk_context/mod.rs
Auto-merging src/librustc/ty/structural_impls.rs
Auto-merging src/librustc/ty/query/plumbing.rs
Auto-merging src/librustc/ty/query/mod.rs
Auto-merging src/librustc/ty/query/config.rs
Auto-merging src/librustc/ty/mod.rs
Auto-merging src/librustc/ty/fold.rs
Auto-merging src/librustc/ty/context.rs
Auto-merging src/librustc/traits/structural_impls.rs
Auto-merging src/librustc/traits/select.rs
Auto-merging src/librustc/traits/mod.rs
Auto-merging src/librustc/traits/fulfill.rs
Auto-merging src/librustc/traits/error_reporting.rs
Auto-merging src/librustc/traits/engine.rs
Auto-merging src/librustc/traits/auto_trait.rs
Auto-merging src/librustc/infer/mod.rs
Auto-merging src/librustc/infer/canonical/query_response.rs
Auto-merging src/librustc/infer/canonical/mod.rs
Auto-merging src/librustc/infer/canonical/canonicalizer.rs
Auto-merging src/librustc/ich/impls_ty.rs
Auto-merging src/librustc/dep_graph/dep_node.rs
Auto-merging Cargo.lock
CONFLICT (content): Merge conflict in Cargo.lock
Automatic merge failed; fix conflicts and then commit the result.

@scalexm scalexm force-pushed the scalexm:chalk branch from 9dab10d to 993d213 Dec 27, 2018

@scalexm

This comment has been minimized.

Copy link
Member

scalexm commented Dec 27, 2018

@bors r=nikomatsakis

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 27, 2018

📌 Commit 993d213 has been approved by nikomatsakis

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 27, 2018

⌛️ Testing commit 993d213 with merge fb86d60...

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

Auto merge of #56384 - scalexm:chalk, r=nikomatsakis
Implement the new-style trait solver

Final PR of what I believe to be a minimally working implementation of the new-style trait solver.

The new trait solver can be used by providing the `-Z chalk` command line flag. It is currently used everywhere in `rustc_typeck`, and for everything relying on `rustc::infer::canonical::query_response::enter_canonical_trait_query`.

The trait solver is invoked in rustc by using the `evaluate_goal` canonical query. This is not optimal because each call to `evaluate_goal` creates a new `chalk_engine::Forest`, hence rustc cannot use answers to intermediate goals produced by the root goal. We'll need to change that but I guess that's ok for now.

Some next steps, I think, are:
* handle region constraints: region constraints are computed but are completely ignored for now, I think we may need additional support from `chalk_engine` (as a side effect, types or trait references with outlive requirements cannot be proved well-formed)
* deactivate eager normalization in the presence of `-Z chalk` in order to leverage the lazy normalization strategy of the new-style trait solver
* add the remaining built-in impls (only `Sized` is supported currently)
* transition the compiler to using generic goals instead of predicates that still refer to named type parameters etc

I added a few very simple tests to check that the new solver has the right behavior, they won't be needed anymore once it is mature enough. Additionally it shows off that we get [implied bounds](#44491) for free.

r? @nikomatsakis
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 27, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing fb86d60 to master...

@bors bors merged commit 993d213 into rust-lang:master Dec 27, 2018

2 checks passed

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