gccrs: Index ImplTrait Blocks in Trait map for better filtering
gccrs maps trait implementation blocks for improved filtering during trait probing.
The GCC Rust frontend now indexes implementation trait blocks and stores them in the trait map. This allows for more efficient filtering during trait probing, preventing the compiler from needing to scan the entire crate. By directly mapping trait implementations, the compiler can quickly locate relevant trait information, speeding up compilation for projects with extensive trait usage.
In Details
gccrs introduces new helpers in util/rust-hir-map.cc to insert and manage trait_impl_mappings. This data structure is populated during AST lowering (hir/rust-ast-lower-item.cc). The PathProbeImplTrait in typecheck/rust-hir-path-probe.cc now utilizes these mappings for more efficient processing of trait implementations, avoiding full crate scans.
- trait map
- An internal data structure within gccrs used to store and quickly access information about traits and their implementations. It helps the compiler manage and look up trait-related metadata.
- ImplTrait Blocks
- Code blocks in Rust that define how a specific trait is implemented for a specific type. These blocks contain the method implementations required by the trait.
- trait probing
- The process by which the compiler investigates and verifies trait implementations for a given type, often to ensure required methods are available or to resolve trait-specific logic.
- gccrs
- The GCC frontend for the Rust programming language. It aims to integrate Rust compilation capabilities into the GCC toolchain.