gccrs: Improve type path resolution for direct trait lookup
gccrs now directly performs trait lookups during type path resolution, fixing accidental working behavior.
The GCC Rust frontend refactors type path resolution to directly perform trait lookups, addressing a previous reliance on accidental correctness. The compiler now explicitly checks trait bounds during path resolution, ensuring that types satisfy requirements before operations proceed. This change improves the robustness of type checking, especially for complex trait relationships.
In Details
In typecheck/rust-hir-type-check-path.cc, TypeCheckExpr::visit now directly performs trait lookups. Previously, this worked by chance because the type bounds probe had already set up the checked trait. This commit corrects the logic to ensure trait satisfaction is explicitly verified during expression type checking.
- trait lookup
- The process of searching for and verifying the implementation of a specific trait for a given type. This is crucial for ensuring that methods defined by a trait can be called on an object of that type.
- type path resolution
- The compiler's process of determining the meaning and type of an identifier or expression that may involve nested paths, modules, or generic types. It resolves potential ambiguities to find the correct type.
- type checking
- The process by which a compiler verifies that the types of values used in a program are consistent with the language's rules and the types declared for them.
- gccrs
- The GCC frontend for the Rust programming language. It aims to integrate Rust compilation capabilities into the GCC toolchain.