Skip to content

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

Merged
merged 2 commits into from
Jul 11, 2025

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Jul 11, 2025

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.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jul 11, 2025
@aibaars aibaars marked this pull request as ready for review July 11, 2025 13:04
@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 13:04
@aibaars aibaars requested a review from a team as a code owner July 11, 2025 13:04
Copy link
Contributor

@Copilot 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 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

Copy link
Contributor

@hvitved hvitved left a 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:?
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@aibaars aibaars force-pushed the aibaars/more-pattern-tests branch from 4d1691f to 519905e Compare July 11, 2025 14:00
@aibaars aibaars merged commit 14a362d into main Jul 11, 2025
15 checks passed
@aibaars aibaars deleted the aibaars/more-pattern-tests branch July 11, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy