rust/compiler
nils e79b182fca
Rollup merge of #108896 - BoxyUwU:new_solver_add_goal_fn, r=lcnr
new solver: make all goal evaluation able to be automatically rerun

It is generally wrong to call `evaluate_goal` multiple times or `evaluate_goal` and `evaluate_all` for the same `QueryResult` without correctly handling rerunning the goals when inference makes progress. Not doing so will result in the assertion in `evaluate_goal` firing because rerunning the goal will lead to a more accurate `QueryResult`.

Currently there are lots of places that get this wrong and generally it is complex and error prone to handle correctly everywhere. This PR introduces a way to add goals to the `EvalCtxt` and then run all the added goals in a loop so that `evaluate_goal`/`evaluate_all` is not necessary to call manually.

There are a few complications for making everything work "right":
1. the `normalizes-to` hack that replaces the rhs with an unconstrained infer var requires special casing in the new `try_evaluate_added_goals` function similar to how `evaluate_goal`'s assertion special cases that hack.

2. `assemble_candidates_after_normalizing_self_ty`'s normalization step needs to be reran for each candidate otherwise the found candidates will potentially get a more accurate `QueryResult` when rerunning the projection/trait goal which can effect the `QueryResult` of the projection/trait goal.
This is implemented via `EvalCtxt::probe`'s closure's `EvalCtxt` inheriting the added goals of the `EvalCtxt` that `probe` is called on, allowing us to add goals in a probe, and then enter a nested probe for each candidate and evaluate added goals which include the normalization step's goals.

I made `make_canonical_response` evaluate added goals so that it will be hard to mess up the impl of the solver by forgetting to evaluate added goals. Right now the only way to mess this up would be to call `response_no_constraints` (which from the name is obviously weird).

The visibility of `evaluate_goal` means that it can be called from various `compute_x_goal` or candidate assembly functions, this is generally wrong and we should never call `evaluate_goal` manually, instead we should be calling `add_goal`/`add_goals`. This is solved by moving `evaluate_goal` `evaluate_canonical_goal` and `compute_goal` into `eval_ctxt`'s module and making them private so they cannot be called from elsewhere, forcing people to call `add_goal/s` and `evaluate_added_goals_and_make_canonical_resposne`/`try_evaluate_added_goals`

---

Other changes:
- removed the `&& false` that was introduced to the assertion in `evaluate_goal` in #108839
- remove a `!self.did_overflow()` requirement in `search_graph.is_empty()` which causes goals that overflow to ICE
- made `EvalCtxt::eq` take `&mut self` and add all the nested goals via `add_goals` instead of returning them as 99% of call sites just immediately called `EvalCtxt::add_goals` manually.

r? `````@lcnr`````
2023-03-21 13:00:22 +01:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Unify validity checks into a single query 2023-02-23 18:42:36 +00:00
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors 2023-03-17 08:42:37 +01:00
rustc_ast_lowering Gate fmt args flattening behind -Zflatten-format-args. 2023-03-16 11:21:50 +01:00
rustc_ast_passes Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31 2023-03-13 10:41:50 +00:00
rustc_ast_pretty Remove box_syntax from AST and use in tools 2023-03-12 13:19:46 +00:00
rustc_attr Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_baked_icu_data update ICU4X to 1.1.0 2023-02-04 22:28:59 +01:00
rustc_borrowck Rollup merge of #109215 - est31:sort_by_key, r=Nilstrieb 2023-03-17 08:42:40 +01:00
rustc_builtin_macros Rollup merge of #109301 - Ezrashaw:fix-ctf-ice, r=Nilstrieb 2023-03-20 07:10:31 +01:00
rustc_codegen_cranelift Tweak implementation of overflow checking assertions 2023-03-16 22:55:45 +01:00
rustc_codegen_gcc Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
rustc_codegen_llvm Rollup merge of #108726 - est31:backticks_matchmaking_tidy, r=Nilstrieb 2023-03-12 08:13:25 +01:00
rustc_codegen_ssa Rollup merge of #109307 - cjgillot:inline-location, r=compiler-errors 2023-03-20 09:46:54 +01:00
rustc_const_eval Rollup merge of #109307 - cjgillot:inline-location, r=compiler-errors 2023-03-20 09:46:54 +01:00
rustc_data_structures migrate compiler, bootstrap, and compiletest to windows-rs 2023-03-20 13:19:35 -04:00
rustc_driver Remove unneeded extern crate 2023-02-02 07:47:39 +01:00
rustc_driver_impl migrate compiler, bootstrap, and compiletest to windows-rs 2023-03-20 13:19:35 -04:00
rustc_error_codes Rollup merge of #107416 - czzrr:issue-80618, r=GuillaumeGomez 2023-03-18 12:04:21 +01:00
rustc_error_messages Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_errors migrate compiler, bootstrap, and compiletest to windows-rs 2023-03-20 13:19:35 -04:00
rustc_expand Suggest surrounding the macro with {} to interpret as a statement 2023-03-17 14:36:22 +08:00
rustc_feature Bump version placeholders 2023-03-15 08:55:22 -04:00
rustc_fs_util
rustc_graphviz Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_hir Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors 2023-03-17 08:42:37 +01:00
rustc_hir_analysis Rollup merge of #109364 - compiler-errors:gat-const-arg, r=BoxyUwU 2023-03-20 09:46:54 +01:00
rustc_hir_pretty Remove box expressions from HIR 2023-03-14 17:18:26 +00:00
rustc_hir_typeck Rollup merge of #109212 - Ezrashaw:no-similar-sugg-for-unstable, r=estebank 2023-03-19 15:33:58 +05:30
rustc_incremental Auto merge of #108794 - nnethercote:avoid-unnecessary-hashing, r=cjgillot 2023-03-12 06:48:30 +00:00
rustc_index Match unmatched backticks in compiler/ that are part of rustdoc 2023-03-03 08:39:00 +01:00
rustc_infer Rollup merge of #105793 - lukas-code:circular-deps, r=Mark-Simulacrum 2023-03-19 15:33:55 +05:30
rustc_interface Gate fmt args flattening behind -Zflatten-format-args. 2023-03-16 11:21:50 +01:00
rustc_lexer fix(lexer): not skipped whitespace warning for '\x0c' 2023-03-09 22:44:58 +08:00
rustc_lint remove bad comment 2023-03-20 00:55:36 +01:00
rustc_lint_defs Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen 2023-03-15 11:44:12 +00:00
rustc_llvm Remove an extraneous include 2023-03-07 22:46:39 -08:00
rustc_log Rollup merge of #107895 - matthiaskrgr:cl, r=compiler-errors 2023-02-11 17:18:44 +01:00
rustc_macros Allow using bool for optional diagnostics 2023-02-27 12:54:11 +00:00
rustc_metadata Rollup merge of #109362 - nnethercote:split-meta-stats-items, r=bjorn3 2023-03-20 07:10:34 +01:00
rustc_middle Enforce non-lifetime-binders in supertrait preds are not object safe 2023-03-20 22:38:57 +00:00
rustc_mir_build address review comments 2023-03-18 00:43:37 -05:00
rustc_mir_dataflow Use index based drop loop for slices and arrays 2023-03-14 21:29:32 +01:00
rustc_mir_transform Auto merge of #108944 - cjgillot:clear-local-info, r=oli-obk 2023-03-16 19:59:56 +00:00
rustc_monomorphize Rollup merge of #109109 - compiler-errors:polymorphize-foreign, r=Nilstrieb 2023-03-15 17:51:31 +05:30
rustc_parse Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31 2023-03-13 10:41:50 +00:00
rustc_parse_format Improve heuristics for format_args literal being suggestable 2023-03-14 13:20:39 +00:00
rustc_passes Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors 2023-03-17 08:42:37 +01:00
rustc_plugin_impl Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_privacy Rename impl_trait_in_trait_parent to impl_trait_in_trait_parent_fn 2023-03-15 12:27:16 -03:00
rustc_query_impl Ensure value is on the on-disk cache before returning. 2023-03-11 22:41:01 +00:00
rustc_query_system Auto merge of #109046 - Zoxc:split-execute-job, r=cjgillot,michaelwoerister 2023-03-20 23:53:09 +00:00
rustc_resolve Rollup merge of #109257 - petrochenkov:bindebug, r=WaffleLapkin 2023-03-18 00:05:55 +01:00
rustc_serialize Emit the enum discriminant separately for the Encodable macro 2023-02-25 01:04:56 +01:00
rustc_session migrate compiler, bootstrap, and compiletest to windows-rs 2023-03-20 13:19:35 -04:00
rustc_smir Change item collection to be on demand 2023-03-07 12:47:25 -08:00
rustc_span Rollup merge of #109307 - cjgillot:inline-location, r=compiler-errors 2023-03-20 09:46:54 +01:00
rustc_symbol_mangling Simplify message paths 2023-03-11 22:51:57 +01:00
rustc_target Fix riscv64 fuchsia LLVM target name 2023-03-15 12:55:37 +09:00
rustc_trait_selection Rollup merge of #108896 - BoxyUwU:new_solver_add_goal_fn, r=lcnr 2023-03-21 13:00:22 +01:00
rustc_traits Add mk_canonical_var_infos_from_iter. 2023-02-24 07:33:02 +11:00
rustc_transmute rustc_middle: Remove trait DefIdTree 2023-03-02 23:46:44 +04:00
rustc_ty_utils Rollup merge of #109277 - spastorino:new-rpitit-14, r=compiler-errors 2023-03-20 09:46:53 +01:00
rustc_type_ir Rollup merge of #109047 - tshepang:type, r=lcnr 2023-03-12 20:44:52 +01:00