Rust: Minor tweaks to certain type inference#20299
Merged
paldepind merged 5 commits intogithub:mainfrom Aug 27, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refines Rust type inference by addressing inconsistencies in pattern matching, making logical operators have certain type inference, and adding support for range expressions including the .. (RangeFull) operator.
- Fixes type inference inconsistency where multiple certain types could be inferred for the same node due to match ergonomics/binding modes in pattern matching
- Makes inference of logical operators and range expressions certain
- Adds support for the
..range expression (RangeFull)
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rust/ql/test/library-tests/type-inference/pattern_matching.rs | Adds test cases for tuple pattern matching on references to verify binding mode fixes |
| rust/ql/test/library-tests/type-inference/main.rs | Adds test for RangeFull range expression and minor struct formatting cleanup |
| rust/ql/lib/codeql/rust/internal/TypeInference.qll | Core type inference logic updates: restricts certain type equality to IdentPat, moves logical/range operators to certain inference, and adds LetExpr type equality |
| rust/ql/lib/codeql/rust/frameworks/stdlib/Stdlib.qll | Defines RangeFullStruct class for the core::ops::range::RangeFull type |
| rust/ql/lib/codeql/rust/elements/RangeExprExt.qll | Adds RangeFullExpr class to represent .. range expressions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
..range.