gccrs: Fix IdentifierPathPass to handle sub-patterns
IdentifierPathPass now correctly processes sub-patterns in Rust code, fixing a bug and adding a new test.
The IdentifierPathPass in gccrs has been fixed to correctly handle sub-patterns within Rust code. Previously, it might have failed to traverse and process these sub-patterns when they were part of a larger pattern. This commit ensures that all sub-patterns are visited, resolving a bug and preventing potential incorrect code generation or analysis. A new test case has been added to verify this fix.
In Details
The IdentifierPathPass in gccrs's name resolution phase had a bug where it did not correctly reseat and visit sub-patterns within Pattern constructs when they were not converted into PathInExpression. This commit modifies the reseat method to ensure that sub-patterns are always visited, regardless of their conversion status. This fixes a potential issue in handling complex pattern matching in Rust code. A new test rust/execute/ident_pat_vs_path_3.rs is added to cover this scenario.
- gccrs
- The GCC Rust frontend, responsible for parsing, type-checking, and generating code for Rust programs using the GCC compiler infrastructure.
- IdentifierPathPass
- A pass within the gccrs name resolution system that processes paths (e.g., module paths, type paths) to identify and resolve identifiers in Rust code.
- Pattern
- In Rust, a pattern is used in constructs like
matchexpressions andletbindings to destructure data and bind variables. Patterns can themselves contain nested structures. - PathInExpression
- A specific form of path in Rust code that appears within an expression, often used for accessing modules, types, or functions.