Walks binding generic arguments for unconstrained checks
GCC Rust now correctly checks generic arguments within type bindings for unconstrained issues.
This commit enhances GCC Rust’s type checking by ensuring that generic arguments within type bindings are properly walked to identify unconstrained issues. This fix addresses two specific cases (Rust-GCC/gccrs#4862 and #4863) where the compiler failed to detect or correctly handle situations involving unconstrained generics in bindings.
In Details
The gccrs type checker now iterates through generic arguments of type bindings during the visit process. This allows for the detection of unconstrained type parameters within these bindings, which is crucial for the correctness of type unification and inference. The change is in typecheck/rust-hir-type-check-base.cc.
- type bindings
- In Rust, this can refer to associated types in traits or type aliases, where a specific type is bound to a generic placeholder or a name.
- generic arguments
- Placeholders used in generic types, functions, or traits that can be replaced by specific types at compile time. For example, in
Vec<T>,Tis a generic argument. - unconstrained
- Refers to a generic type parameter that does not have any trait bounds or other constraints specified, meaning it could potentially be any type. This can lead to ambiguity or compilation errors if not handled correctly.