Predicate/clause cleanups#157104
Conversation
And insert some blank lines.
`check_predicates` currently does the following. - Builds `impl2_predicates` by gathering some clauses and converting them into predicates. - Extends `impl2_predicates` with some actual predicates from `elaborate`. - Iterates over `impl1_predicates` (which are actually clauses), converting each clause to a predicate in order to look for a match with any predicate in `impl2_predicates`. After this commit it instead does the following. - Builds `impl2_clauses` by gathering some clauses. - Extends `impl2_clauses` with only the predicates from `elaborate` that are clauses (pre-filtering out non-clause predicates). - Iterates over `impl1_clauses` (now correctly named), to look for a match with any clause in `impl2_clauses`. I.e. instead of promoting clauses to predicates and doing some comparisons that can't succeed, we pre-filter any non-clause predicates before doing the comparisons.
`deduce_closure_signature_from_predicates` currently takes a `Predicate` iterator. But it ignores any predicates that are not clauses. This commit changes it to take a `Clause` iterator. The change requires one call site to pre-filter any non-clause predicates, but also lets another site avoid uselessly promoting clauses to predicates.
`get_future_output` takes a predicate, but can only succeed if the predicate is a clause. This commit changes it to take a clause. This requires changing one call site to pre-filter any non-clause predicates, but also lets another site avoid uselessly promoting clauses to predicates.
`Predicate` already implements `Flags`. By adding an impl of `Flags` for `Clause`, we can call `flags` and `outer_exclusive_binder` directly on clauses, instead of having to convert them to predicates first.
`caller_bounds` returns a sequence of clauses, but all the call sites use variables as if it returns predicates. Similarly, `assemble_candidates_from_predicates` actually takes clauses, not predicates. This commit renames things appropriately, replacing name mixups like `tcx.mk_clauses(&predicates)` with `tcx.mk_clauses(&clauses)`.
`evaluate_predicates` creates some predicate lists from clauses, and then later converts them back to clauses. This commit avoids this back and forth. The only tricky part is the addition of an `expect_clause` call in `evaluate_nested_obligations` to extract a clause from a predicate that we've already matched as a clause.
Currently they both take arguments that can be upcast into a predicate. But in practice the arguments at all call sites are things that can be upcast to a clause. So this commits changes their names and types to work with clauses, which are more specific.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Predicate/clause cleanups
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (ddecfc1): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -5.2%, secondary -2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.0%, secondary 0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 510.27s -> 513.645s (0.66%) |
Clauseis a subset ofPredicate, more or less. (Interning makes things slightly more complicated than that.) There are numerous places where the code deals in predicates but really only clauses are possible. This PR eliminates some of them. Details in individual commits.