Skip to content

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Jan 26, 2026

In the shared type inference library the TypeMention class really just duplicates the content of the HasTypeTreeSig.

This PR turns TypeMention into a parameter to the module. The parameter uses HasTypeTreeSig which removes the duplication. This also gets rid of TypeMentionTypeTree in the shared library.

Adapting Rust is done in two commits. The first is the minimum necessary changes. Here TypeMentionTypeTree still exists on the Rust side. In a second commit Rust's TypeMention is made to directly implement HasTypeTreeSig by renaming resolveTypeAt to getTypeAt. 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".

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jan 26, 2026
@paldepind paldepind changed the title Shared/type mention tree Shared, Rust: Use HasTypeTreeSig for TypeMention Jan 26, 2026
@paldepind paldepind changed the title Shared, Rust: Use HasTypeTreeSig for TypeMention Shared, Rust: Use HasTypeTreeSig for TypeMention Jan 26, 2026
@paldepind paldepind requested a review from hvitved January 26, 2026 09:11
@paldepind paldepind marked this pull request as ready for review January 26, 2026 09:16
@paldepind paldepind requested review from a team as code owners January 26, 2026 09:16
Copilot AI review requested due to automatic review settings January 26, 2026 09:16
@paldepind paldepind added the no-change-note-required This PR does not need a change note label Jan 26, 2026
Copy link
Contributor

Copilot AI left a 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 InputSig2 in the shared library with HasTypeTreeSig TypeMention, removing duplication
  • Renamed resolveTypeAt to getTypeAt and resolveType to getType throughout Rust's type inference implementation
  • Removed the TypeMentionTypeTree adapter 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.

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor!

@paldepind
Copy link
Contributor Author

DCA shows nothing as expected.

@paldepind paldepind merged commit 793d2c7 into github:main Jan 26, 2026
60 of 61 checks passed
@paldepind paldepind deleted the shared/type-mention-tree branch January 26, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants