-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't build ParamEnv
and do trait solving in ItemCtxt
s when lowering IATs
#140247
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
base: master
Are you sure you want to change the base?
Conversation
This PR changes a file inside HIR ty lowering was modified cc @fmease |
} | ||
|
||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { | ||
if let ty::Alias(_, _) = ty.kind() { |
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.
Possibly we're supposed to handle free type aliases specially here instead of replacing them with inference variables as it should be possible to just normalize them. Though that's not the behaviour that would happen w/ new solver deferred projection equality + ignoring returned goals
// are unable to explicitly disambiguate which impl to use other than by specifying the | ||
// self type. | ||
|
||
struct ReplaceAliasesWithInfer<'tcx, 'a>(&'a InferCtxt<'tcx>); |
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.
Do we need this folder w/ the new solver? We could just relate and throw away all the alias-relate predicates?
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.
Yeah with the new solver this is unnecessary
☔ The latest upstream changes (presumably #140388) made this pull request unmergeable. Please resolve the merge conflicts. |
3361c7d
to
34ce403
Compare
Fixes #108491
Fixes #125879
This was due to updating inhabited predicate stuff which I had to do to make constructing ADTs with IATs in fields not ICE
Fixes #136678 (but no test added, I don't rly care about weird IAT edge cases under GCE)
Fixes #138131
Fixes #138166
Idk random mgca/iat garbage(?) Not sure why these ICEd or why they now don't.
Avoids doing "fully correct" candidate selection for IATs during hir ty lowering when in item signatures as it almost always leads to a query cycle from trying to build a
ParamEnv
. I replaced it with a "simple" heuristic that assumes all aliases are equal to all other aliases and tries to unify the self type with self type of each candidate's impl.A potential alternative would be to replace all the generic parameters in the self type with inference variables as then it would be "truly" environment agnostic. I think this is somewhat subpar as we would be weakening how much we used the self type to guide candidate selection and that's the only way for the user to attempt to specify which IAT to resolve to.
In general that's also why I think doing something hacky here instead of just throwing our hands up and saying "ItemCtxts should make inference variables" and not filtering any candidates out, is a good idea (there is no way for users to disambiguate such cases).
I'm not really sure how this interacts with #126651, though I'm also not really sure its super important to support projecting IATs from IAT self types given we don't even support
T::Assoc::Other
for trait-associated types so didn't give much thought to how this might fit in with that.r? @compiler-errors
cc @fmease