-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Do not emit alias-eq when instantiating a type var from a canonical response in the new solver #109037
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
@@ -144,6 +144,13 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> { | |||
} | |||
} | |||
|
|||
// Inside the generalizer, we want to related projections by substs eagerly. | |||
(&ty::Alias(ty::Projection, a_data), &ty::Alias(ty::Projection, b_data)) | |||
if self.fields.relate_projections_via_substs => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am somewhat unhappy with this and hope that it can be avoided. I feel like this is fairly related to #105787 so maybe we can talk about these in sync?
I think the approach this PR takes is not correct. This ended up kind of a huge comment, sorry for giant wall of TEXT :< I think generalizer right now is wrong for projections. The case of If we imagine Fixing this will be incompatible with the way that this PR currently has This could probably be fixed by just Not setting Instantiation relating the substs of projections when doing Generalizer has a special case to avoid creating new infer vars for invariant positions except for the situation where the var being instantiated is in a lower universe than the variable being generalized. So we can actually end up in a situation where generalizing a projection results in a type that is not
If we were to relate the substs of these two projections This is likely unsound during coherence as it would cause I suspect that you could get the same issue with This could probably be fixed by only setting I am not entirely sure what lcnr's plan for the FIXME in If we wanted to handle I haven't talked about the somewhat more subjective complaints about this PR (generally the solution having a "hacky" vibe that is probably a soundness footgun as relating substs is generally Very Wrong) since I think the more objective problems (this PR being unsound as is) are more important. |
we only use
good catch :o yeah, that would be incomplete and unsound during coherence, though definitely very hard to trigger |
…ligations, r=lcnr Return nested obligations from canonical response var unification Handle alias-eq obligations being emitted from `instantiate_and_apply_query_response` in: * `EvalCtxt` - by processing the nested obligations in the next loop by `new_goals` * `FulfillCtxt` - by adding the nested obligations to the fulfillment's pending obligations * `InferCtxt::evaluate_obligation` - ~~by returning `EvaluationResult::EvaluatedToAmbig` (boo 👎, see the FIXME)~~ same behavior as above, since we use fulfillment and `select_where_possible` The only one that's truly sketchy is `evaluate_obligation`, but it's not hard to modify this behavior moving forward. From rust-lang#109037, I think a smaller repro could be crafted if I were smarter, but I am not, so I just took this from rust-lang#105878. r? `@lcnr` cc `@BoxyUwU`
When instantiating a canonical response, don't emit an alias-eq goals if the response type is a projection that is generalized in
Equate
.I think a smaller repro could be crafted if I were smarter, but I am not, so I just took this from #105878.