-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Shared, Rust: Use HasTypeTreeSig for TypeMention
#21215
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
Conversation
HasTypeTreeSig for TypeMention
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.
Pull request overview
This PR refactors the shared type inference library to eliminate code duplication by making TypeMention a parameter to the Make2 module that uses the HasTypeTreeSig signature. The Rust implementation is adapted by renaming resolveTypeAt to getTypeAt and resolveType to getType to directly implement the HasTypeTreeSig interface, removing the need for the TypeMentionTypeTree adapter class.
Changes:
- Parameterized
InputSig2in the shared library withHasTypeTreeSig TypeMention, removing duplication - Renamed
resolveTypeAttogetTypeAtandresolveTypetogetTypethroughout Rust's type inference implementation - Removed the
TypeMentionTypeTreeadapter class from both shared and Rust libraries
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| shared/typeinference/codeql/typeinference/internal/TypeInference.qll | Parameterized InputSig2 with HasTypeTreeSig TypeMention, removed TypeMentionTypeTree adapter, renamed internal helpers from resolveTypeMentionRoot to getTypeMentionRoot, updated documentation |
| rust/ql/lib/codeql/rust/internal/typeinference/TypeMention.qll | Renamed resolveTypeAt to getTypeAt and resolveType to getType in TypeMention class and all subclasses |
| rust/ql/lib/codeql/rust/internal/typeinference/TypeInferenceConsistency.qll | Updated call from resolveType() to getType() |
| rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll | Updated module instantiation to use Make2<TypeMention, Input2>, updated all call sites to use getTypeAt |
| rust/ql/lib/codeql/rust/internal/typeinference/FunctionType.qll | Updated calls from resolveTypeAt to getTypeAt |
| rust/ql/lib/codeql/rust/internal/typeinference/FunctionOverloading.qll | Updated calls from resolveTypeAt to getTypeAt and resolveType to getType |
| rust/ql/lib/codeql/rust/internal/typeinference/DerefChain.qll | Updated call from resolveTypeAt to getTypeAt |
| rust/ql/lib/codeql/rust/internal/typeinference/BlanketImplementation.qll | Updated calls from resolveType to getType and resolveTypeAt to getTypeAt |
| rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll | Updated calls from resolveType to getType |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hvitved
left a comment
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.
Nice refactor!
|
DCA shows nothing as expected. |
In the shared type inference library the
TypeMentionclass really just duplicates the content of theHasTypeTreeSig.This PR turns
TypeMentioninto a parameter to the module. The parameter usesHasTypeTreeSigwhich removes the duplication. This also gets rid ofTypeMentionTypeTreein the shared library.Adapting Rust is done in two commits. The first is the minimum necessary changes. Here
TypeMentionTypeTreestill exists on the Rust side. In a second commit Rust'sTypeMentionis made to directly implementHasTypeTreeSigby renamingresolveTypeAttogetTypeAt. As far as I recall that rename was discussed previously with some disagreement. So consider the last commit a proposal that we can potentially drop from the PR. Personally I like it as it simplifies things and I don't see much difference between using "get" or "resolve".