Motivation
Currently, several AST structures in parse.rs (such as TypeAlias and Function) manually define a file_id: usize field to distinguish between identical structures across different files. It would be much cleaner to embed this file_id directly into the Span structure itself.
The Problem
During the parsing stage, we currently initialize this file_id to a dummy value (0). Later, during the driver stage, we mutate the AST to inject the actual file ID generated by the driver. This approach feels like a crutch. It is highly inconvenient because it requires the driver to reach directly into the parsed structs to mutate them.
The Solution
Instead of mutating the AST later, we should compute the file_id directly during the parsing stage. By hashing the specific file and assigning that hash as the file_id upfront, the driver will immediately have access to the correct ID. This significantly simplifies the driver's logic.
Motivation
Currently, several AST structures in
parse.rs(such asTypeAliasandFunction) manually define afile_id: usizefield to distinguish between identical structures across different files. It would be much cleaner to embed thisfile_iddirectly into theSpanstructure itself.The Problem
During the parsing stage, we currently initialize this
file_idto a dummy value (0). Later, during the driver stage, we mutate the AST to inject the actual file ID generated by the driver. This approach feels like a crutch. It is highly inconvenient because it requires the driver to reach directly into the parsed structs to mutate them.The Solution
Instead of mutating the AST later, we should compute the
file_iddirectly during the parsing stage. By hashing the specific file and assigning that hash as thefile_idupfront, the driver will immediately have access to the correct ID. This significantly simplifies the driver's logic.