lub instead of relying on structural identity in coerce lub #147228
+27
−29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes rust-lang/trait-system-refactor-initiative#233
the
|x| x + 1
expr has a type ofClosure(?31t)
which we wind up inferring the RPIT to. TheCoerceMany
ret_coercion
for the wholepeculiar
typeck has an expected type ofRPIT
(unnormalized). When we type check thereturn |x| x + 1
expr we go from the never type toClosure(?31t)
which then participates in theret_coercion
giving us acoerce-lub(RPIT, Closure(?31t))
.Normalizing
RPIT
gives us someClosure(?50t)
where?31t
and?50t
have been unified with?31t
as the root var.resolve_vars_if_possible
doesn't resolve infer vars to their roots so these wind up with different structural identities so the fast path doesn't apply and we fall back to coercing to afn
ptr. cc #147193 which also fixes thisNew solver probably just gets more inference variables here because canonicalization + generally different approach to normalization of opaques. Idk :3
In theory I feel like using a lub here ought to cause other code to work that currently doesn't 🤔 E.g. if the two types only differ in normalization. I'm not certain about how to construct such an example though :3
r? lcnr