gccrs: Fix constant path handling.
Ensures constants within paths are handled correctly during pattern matching and compilation.
This commit corrects how gccrs handles constants that appear within paths, specifically in the context of pattern matching and expression compilation. It resolves an issue (Rust-GCC/gccrs#4851) by updating CompilePatternCheckExpr::visit and TypeCheckPattern::visit to correctly process non-ADT (Algebraic Data Type) paths that involve constants.
In Details
The CompilePatternCheckExpr::visit in backend/rust-compile-pattern.cc and TypeCheckPattern::visit in typecheck/rust-hir-type-check-pattern.cc have been updated. These changes ensure that when a path includes a constant (not part of an ADT), it is correctly recognized and processed during pattern compilation and type checking, resolving a specific bug related to constant paths.
- paths
- In Rust, paths are used to refer to items like modules, functions, structs, and traits, often involving hierarchical namespaces (e.g.,
std::collections::HashMap). - pattern matching
- A mechanism in Rust used to destructure data and conditionally execute code based on the structure and values of the data. It's commonly used in
matchexpressions and function arguments. - ADT (Algebraic Data Type)
- A composite type formed by combining other types. In Rust, enums and structs are forms of ADTs. They represent a sum of possibilities (enums) or a record of fields (structs).