gccrs: Partially support x@.. in SlicePattern
GCC Rust compiler now supports bound rest patterns in slice patterns.
This commit partially enables support for slice patterns with bound rest patterns (e.g., x@..) in GCC’s Rust front-end. While full type checking and GENERIC compilation for these patterns are still pending, the compiler now handles them in various stages, including borrow checking and HIR lowering, preventing premature errors.
In Details
Support for slice patterns with bound rest elements (x@..) is extended in gccrs. Specifically, the CompilePatternBindings::visit (SlicePattern) and TypeCheckPattern::visit (SlicePattern) methods now correctly handle cases where the rest pattern is bound, although they still assert that it's unsupported for full compilation to GENERIC. The HIR lowering and AST validation also gain support. The SlicePatternItemsHasRest HIR structure is updated to track the bound rest element.
- slice pattern
- A pattern matching construct in Rust used to destructure slices. It can match elements at the beginning and end, and optionally capture the remaining elements.
- bound rest pattern
- A feature within Rust's slice patterns where the remaining elements (indicated by
..) are captured into a variable, using syntax likevariable@... - GENERIC
- GCC's first internal intermediate representation (IR). It's a high-level, tree-based representation used after initial parsing and before lower-level optimizations.
- HIR
- High-level Intermediate Representation. A representation used in gccrs after parsing and before lowering to BIR, often closer to the AST but with some semantic information added.