Rust: Simple type inference for index expressions#19657
Merged
hvitved merged 2 commits intogithub:mainfrom Jun 12, 2025
Merged
Conversation
214079f to
2652887
Compare
351a981 to
d8161df
Compare
d8161df to
133aca0
Compare
geoffw0
reviewed
Jun 11, 2025
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
The DCA report is certainly an improvement.
Code LGTM, though it's my first time looking at the type inference library.
| TRefTypeParameter() or | ||
| TSelfTypeParameter(Trait t) | ||
| TSelfTypeParameter(Trait t) or | ||
| TSliceTypeParameter() |
Contributor
There was a problem hiding this comment.
Out of interest, how are these different? i.e. why is just one TypeParameter() type insufficient?
Contributor
Author
There was a problem hiding this comment.
We model slice types as if there was a special struct Slice<T> = ... type, and TSliceTypeParameter corresponds to the T. So e.g. [i64] translates to Slice<i64>.
geoffw0
approved these changes
Jun 11, 2025
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
I'm happy, up to you if you want to wait for a review from @paldepind as well or not.
paldepind
approved these changes
Jun 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds simple type inference for index expressions like
x[0]. Support is simple because we do not properly model theIndextrait, but instead we only supportVec. Slice and array types are modeled correctly.DCA confirms that we are now able to resolve more calls.