Skip to content

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Oct 23, 2025

Some of the code for AssocFunctionType reminded me a bit of what we have for constraint satisfaction in the shared library. This PR is a small refactor to reuse that functionality.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 23, 2025
@paldepind paldepind marked this pull request as ready for review October 24, 2025 07:15
@paldepind paldepind requested review from a team as code owners October 24, 2025 07:15
@Copilot Copilot AI review requested due to automatic review settings October 24, 2025 07:15
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 AssocFunctionType implementation in Rust type inference to reuse constraint satisfaction functionality from the shared library. The main change simplifies the handling of specialized function types for traits and impl blocks by leveraging existing BaseTypes utilities instead of custom recursive logic.

Key Changes:

  • Refactored AssocFunctionType from a union type with inheritance logic to a simpler single constructor with a helper predicate
  • Replaced custom type parameter resolution with shared library's BaseTypes::conditionSatisfiesConstraintTypeAt
  • Updated all call sites to match the new signature ordering

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
shared/typeinference/codeql/typeinference/internal/TypeInference.qll Exposed BaseTypes module by changing from private to public visibility
rust/ql/lib/codeql/rust/internal/typeinference/FunctionType.qll Major refactor of AssocFunctionType to use shared library constraint satisfaction logic
rust/ql/lib/codeql/rust/internal/typeinference/FunctionOverloading.qll Updated calls to assocFunctionTypeAt to match new return value instead of out parameter
rust/ql/lib/codeql/rust/internal/TypeInference.qll Updated calls to appliesTo to match new parameter ordering

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

pragma[nomagic]
private predicate hasSelfTypeParameterAt(TypePath path) {
this.getTypeParameterAt(path) = TSelfTypeParameter(_)
predicate appliesTo(Function f, ImplOrTraitItemNode i, FunctionPosition pos) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the parameter order here to match assocFunctionTypeAt.

@paldepind paldepind changed the title Rust: WIP Rust: Refactor using shared constraint satisfaction Oct 24, 2025
@paldepind paldepind added the no-change-note-required This PR does not need a change note label Oct 24, 2025

/** Provides logic related to base types. */
private module BaseTypes {
module BaseTypes {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making BaseTypes public was the simples way to get the needed predicates. We could also more surgically export the needed functions, but I'm not sure if that's worth the trouble.

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.

1 participant