Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Sep 25, 2025

Extracted from #20282.

DCA looks good: increase in resolvable calls by 0.353 % points.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Sep 25, 2025
@hvitved hvitved force-pushed the rust/type-inference-union-pointer-never branch from 633926e to 2a814dd Compare September 25, 2025 10:34
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 25, 2025
@hvitved hvitved marked this pull request as ready for review September 25, 2025 14:15
@hvitved hvitved requested a review from a team as a code owner September 25, 2025 14:15
Copilot AI review requested due to automatic review settings September 25, 2025 14: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 adds support for modeling union, never (!), and pointer types in Rust's type system. The changes enhance the type inference system to better handle these Rust type constructs, resulting in improved call resolution capabilities.

Key changes:

  • Added new type representations for union, never, and pointer types to the type system
  • Extended type mention resolution to handle these new type constructs
  • Updated type inference logic to support pointer type parameters

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rust/ql/lib/codeql/rust/internal/Type.qll Adds UnionType, NeverType, and PtrType classes with their type parameters
rust/ql/lib/codeql/rust/internal/TypeMention.qll Adds type mention classes for never and pointer type representations
rust/ql/lib/codeql/rust/internal/TypeInference.qll Extends type inference to handle pointer type parameters
rust/ql/lib/codeql/rust/elements/internal/UnionImpl.qll Adds getStructField method to Union class for field access
rust/ql/test/library-tests/type-inference/type-inference.expected Test expectations updated to reflect improved never type inference
rust/ql/test/query-tests/security/CWE-770/CONSISTENCY/PathResolutionConsistency.expected Test expectations for improved call resolution with pointer casts
rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected Test expectations for improved call resolution with pointer operations
rust/ql/test/extractor-tests/macro-expansion/CONSISTENCY/TypeInferenceConsistency.expected Removes previous type inference inconsistency for union types

Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

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

One tiny comment, otherwise looks really good!

Co-authored-by: Simon Friis Vindum <paldepind@github.com>
@hvitved hvitved requested a review from paldepind September 26, 2025 07:57
Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

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

Nice! With this I think we have support for all forms of types in Rust (maybe with the exception of function pointer types) which is really great!

@hvitved hvitved merged commit c52709a into github:main Sep 26, 2025
18 checks passed
@hvitved hvitved deleted the rust/type-inference-union-pointer-never branch September 26, 2025 08:26
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