-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: add more type inference tests for patterns and a simple one for a closure call #20029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 comprehensive test cases for Rust pattern matching and a simple closure test for type inference. The purpose is to expand test coverage for pattern inference across all pattern types supported by Rust's grammar.
- Adds comprehensive pattern matching test cases covering all major pattern types (literal, identifier, wildcard, range, reference, record, tuple struct, tuple, slice, path, or, box, rest, macro patterns, etc.)
- Adds a simple closure test to verify type inference in closure parameters
- Enables the
box_patterns
feature flag to support box pattern testing
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
rust/ql/test/library-tests/type-inference/type-inference.expected | Updates expected test output with new type inference results from the expanded test cases |
rust/ql/test/library-tests/type-inference/main.rs | Adds comprehensive pattern matching examples and a closure test, enabling box_patterns feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I think we should move the entire pattern_matching
module into a separate pattern_matching.rs
file (just like we already have a dereferences.rs
file).
} | ||
// Catch-all with identifier pattern | ||
other => { | ||
let other_complex = other; // $ MISSING: type=other_complex:? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that this doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
complex_data
has a tuple type.
Thanks to co-pilot for generating the examples
4d1691f
to
519905e
Compare
I just asked co-pilot to generate sample test code that covers all the cases for Pat from the ungrammar.
I had to drop the sample code about "const block patterns" because that rust-lang/rust#138492 has been removed from Rust.