gccrs: Fix ICE with nested patterns in multi-field constructors
Resolves an internal compiler error (ICE) related to nested patterns in Rust multi-field constructors.
An internal compiler error (ICE) occurred in gccrs when processing nested patterns within Rust multi-field constructors. This was due to misaligned sub-patterns and their types in the compiler’s internal representation, causing an assertion failure. The fix repositions sub-patterns to align correctly with their types, resolving the ICE and ensuring proper handling of complex pattern structures.
In Details
The PatStack::pop_head_constructor in rust-hir-pattern-analysis.cc previously appended sub-patterns to the end of a row, while Matrix::specialize prepended their types to a column list. This commit modifies pop_head_constructor to insert sub-patterns at the front of the remaining columns, ensuring correct alignment with types in nested constructor patterns and preventing an ADT assertion failure in split_constructors.
- gccrs
- The GCC frontend for the Rust programming language.
- ICE
- Internal Compiler Error, a condition where the compiler encounters an unrecoverable error during the compilation process, indicating a bug in the compiler itself.
- Pattern Matching
- A mechanism in programming languages (like Rust) that allows complex data structures to be deconstructed and their components bound to variables. Used here in the context of matching values in constructors.
- HIR
- High-level Intermediate Representation. A representation of the code used by the compiler after initial parsing and type checking, but before lower-level optimizations.