Skip to content

Type inference: Reduce code duplication - #23072

Open
hvitved wants to merge 3 commits into
github:mainfrom
hvitved:type-inference-share
Open

hvitved wants to merge 3 commits into
github:mainfrom
hvitved:type-inference-share

Conversation

@hvitved

@hvitved hvitved commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This PR reduces code duplication by merging AccessBaseType and AccessConstraint logic into a single ConstraintMatching module, as originally suggested by @paldepind here. DCA us uneventful for both Rust and Unified, except there appears to be a small performance improvement for Rust.

@hvitved
hvitved force-pushed the type-inference-share branch 7 times, most recently from 1563a10 to fe5b9ae Compare November 11, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Constraint lookup combines distinct bounds on the same trait, allowing satisfaction and type-parameter extraction to use different bounds and produce incorrect type inference.

1 open issue
What changed in this PR

This PR reduces duplication in the shared type-inference library by consolidating matching for declaration types and type-parameter constraints.

Changes:

  • Introduces a unified ConstraintMatching module and constraint-position abstractions.
  • Routes base-type matching and contextual inference through the shared constraint matcher.
  • Extracts helper predicates for disambiguating constraint satisfaction.
File Description
shared/​typeinference/​codeql/​typeinference/​internal/​TypeInference.qll Unifies constraint representations and matching logic, and extracts disambiguation helpers.

Review effort: Max

@hvitved
hvitved force-pushed the type-inference-share branch from fe5b9ae to 79fea46 Compare November 11, 2026 09:46
@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Nov 11, 2026
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Nov 11, 2026
@hvitved
hvitved marked this pull request as ready for review November 11, 2026 12:52
@hvitved
hvitved requested review from a team as code owners November 11, 2026 12:52
@hvitved
hvitved requested a review from paldepind November 11, 2026 12:52

This branch has not been deployed

No deployments
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.

3 participants