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.
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
Track the finalizing node in the specialization graph #70535
Track the finalizing node in the specialization graph #70535
Changes from 6 commits
a1e7495
49ba323
103771c
e8910f5
b00ba38
12d9f4e
fd8f818
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
A bit concerning that an inference context is needed for this. Shouldn't building the specialization graph also compute the necessary information to do this "more directly"? Or is this because of type parameters that are constrained by associated items?
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.
It looks like it kinda does, yeah.
fulfill_implication
is what needs the inference context since it unifies the impls, and it returns theSubsts
to rebase onto intranslate_substs
. It's also called when building the specialization graph, but there we just throw away the result. I'll look into storing the result, but I'm not sure I can figure out how everything works exactly.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.
Hmm, this does not look straightforward, and I think I also lack some understanding about the type checker to do this.
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.
Seems fair, it's easier to infer everything through unification. I suppose the only thing that could be done ahead of time is to get the
Substs
for a less specialized impl, in terms of types from a more specialized impl.That is,
impl<T, U> Foo<U> for Vec<T>
andimpl<'a, X> Foo<() for Vec<&'a X>
would give youSubsts
[&'a X, ()]
, and I guess if you had these on every edge in the specialization graph, you could walk "up" it (i.e. in the "less specialized" direction) by successive substitution.Actually, is that what's necessary? Because it doesn't seem that hard to compute, you'd use
translate_subst
or w/e ahead of time and keep the result.But it can be done in a separate PR.