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

gccrs: Remove metadata export visitor

gccrs: Simplifies metadata export by dumping the AST directly.

This commit removes the dedicated metadata export visitor in gccrs, opting instead to directly dump the Abstract Syntax Tree (AST) into metadata files. This change is made because the existing metadata format is incomplete and does not support trait implementations, which are expected to change soon. While this approach is slower, it is considered more complete and correct for the current state of metadata handling in the compiler.

In Details

The gccrs compiler previously used a visitor pattern (ExportVisItems) to selectively export components of the Rust AST into metadata files. This commit discards that visitor in favor of a simpler, albeit slower, method: directly dumping the entire crate's AST using PublicInterface::gather_export_data. This change anticipates upcoming modifications to the metadata format and prioritizes correctness and completeness over performance for this specific export mechanism, especially given the current lack of support for trait implementations in the metadata.

For Context
metadata export
The process of serializing information about a Rust crate or module into a format that can be read by other tools or compiler components. This metadata typically includes information about functions, types, traits, and their relationships.
visitor pattern
A behavioral design pattern that allows adding new operations to existing data structures (like an AST) without modifying the structure itself. A visitor object encapsulates the new operation and traverses the data structure, applying the operation to each element.
AST (Abstract Syntax Tree)
A tree representation of the abstract syntactic structure of source code. The AST captures the essential structure of the code, ignoring syntax details like whitespace and comments, and is used by the compiler for analysis and transformations.
trait implementation
In Rust, code that provides the concrete behavior for a trait on a specific type. For example, implementing the Display trait for a custom struct allows instances of that struct to be formatted as strings.
Filed Under: gccrsmetadataASTcompiler internals