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

Open
wants to merge 19 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@scalexm
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.

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.

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.

Contributor

mark-i-m commented Dec 1, 2018

The title of this PR is so epic

@bors

This comment has been minimized.

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

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.

}

ty::Projection(_projection_ty) => {
// FIXME: add builtin impls from the associated type values found in

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

Maybe piggy-backing on this FIXME.

var_values: cs.subst,
region_constraints: Vec::new(),

// FIXME: restore this later once we get better at handling regions

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

can you give me an example of what goes wrong here?

This comment has been minimized.

@scalexm

scalexm Dec 17, 2018

Member

There are some lost in the chalk-integration Zulip channel :)

I’ll elaborate on that soon.

@@ -458,7 +459,8 @@ impl context::UnificationOps<ChalkArenas<'gcx>, ChalkArenas<'tcx>>
b: &Kind<'tcx>,
) -> Fallible<UnificationResult<'tcx>> {
self.infcx.commit_if_ok(|_| {
unify(self.infcx, *environment, a, b).map_err(|_| chalk_engine::fallible::NoSolution)
unify(self.infcx, *environment, ty::Variance::Covariant, a, b)

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

Wait, why do we want subtyping here? I think this should be equality (unification)

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

(I'm not sure if we can land this like this, or at least it requires a FIXME for sure)

This comment has been minimized.

@scalexm

scalexm Dec 17, 2018

Member

Yes it’s a hack, I was planning to remove it from the final commit history.

@@ -683,6 +685,13 @@ crate fn evaluate_goal<'a, 'tcx>(
GoalKind::DomainGoal(DomainGoal::WellFormed(WellFormed::Ty(ty)))
),

ty::Predicate::Subtype(predicate) => tcx.mk_goal(

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

Why is this predicate arising exactly? Ah, hmm, I guess the librustc_typeck code requires it. Hmm. I feel like we may want to handle this by extending HhGoal to include a Subtype variant, alongside Unify, though I had always imagined though lowering the subtying rules to logical inference statements.

e.g.,

'a: 'b
T <: U
------
&'a T <: &'a U

One tricky bit though will be the handling of higher-ranked subtying like for<'a> fn(&T) <: ?U -- we presently infer ?U to fn(&T) in such a case, even though e.g. fn(&'static T) would be another option. I guess the "inference suggestions" feature could maybe handle this.

I admit I had kind of hoped to just sidestep this problem 😛 maybe we can avoid piping these Subtype goals into the chalk system for now as a horrible hack or something.

This comment has been minimized.


fn gimme<F: Foo>() { }

// Note: this also tests that `std::process::Termination` is implemented for `()`.

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

Heh, it always takes a lot to bootstrap =)

// The only type which implements `Foo` is `i32`, so the chalk trait solver
// is expecting a variable of type `i32`. This behavior differs from the
// old-style trait solver. I guess this will change, that's why I'm
// adding that test.

This comment has been minimized.

@nikomatsakis

nikomatsakis Dec 17, 2018

Contributor

Yeah, one of the interesting questions we do have to answer is how aggressively we want to be guessing types like this. Right now we are kind of "sometimes aggressive" -- never with Self, but yes with the other parameters. This is not exactly by design though... it just kind of came out that way due to various other constraints.

// `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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment