GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: lang: Add dispatch_from_dyn for Box

Implement dispatch_from_dyn lang item for Box in gccrs.

The gccrs compiler now supports the ‘dispatch_from_dyn’ language item specifically for the ‘Box’ type. This enables correct dynamic dispatch for Boxed values. While other smart pointers could also use this feature, they are not yet fully supported. This change includes updates to the expression compiler, type checker, and language item registration.

In Details

gccrs has added support for the dispatch_from_dyn lang item, which is crucial for dynamic dispatch on types like Box. This commit focuses on the Box receiver case in CompileExpr::visit and extracting the inner type of a Box in MethodResolver::try_hook. The LangItem enum and BiMap are updated to register this new lang item. This is a foundational step for supporting dynamic dispatch on other smart pointers in the future.

For Context
dispatch_from_dyn
A language item in gccrs that enables dynamic dispatch for certain types, allowing method calls on trait objects or other dynamically dispatched types.
Box
A smart pointer in Rust that owns data on the heap. It's analogous to a unique pointer in C++.
dynamic dispatch
A mechanism where the specific function or method to be called is determined at runtime, rather than at compile time. This is typically used for trait objects and virtual method calls.
lang item
A specific, built-in feature or capability of the Rust language that the compiler needs to implement, such as Sized, Copy, or in this case, dispatch_from_dyn.
Filed Under: gccrsrustcompilerlanguage feature