gccrs: Add trait filtering to method resolution probe
gccrs' method resolution now supports trait filtering for pre-filtering candidates.
The GCC Rust frontend enhances its method resolution probe to accept a trait for filtering. This allows the compiler to pre-filter potential method candidates based on trait requirements, rather than scanning the entire crate. This optimization improves the efficiency of resolving method calls, especially in large codebases with many trait implementations.
In Details
The MethodResolver in typecheck/rust-hir-dot-operator.cc now supports an optional trait filter. This allows Probe and related methods to search for methods only within specific trait implementations, rather than performing a broader crate scan. Helper functions in util/rust-hir-map.cc are added to support scanning implblocks for trait mappings.
- method resolution
- The compiler's process of determining which specific method implementation should be called when a method is invoked on an object, especially in the presence of traits and inheritance.
- trait
- A shared interface that defines a set of methods. In Rust, traits enable polymorphism and code reuse, similar to interfaces in other languages.
- probe
- A mechanism within the compiler used to investigate, search for, or verify specific information, such as type definitions, trait implementations, or method candidates.
- gccrs
- The GCC frontend for the Rust programming language. It aims to integrate Rust compilation capabilities into the GCC toolchain.