Currently, the Dump trait exposes internal types of the compiler, which is undesirable. It also forces the trait's implementors to write lowering code (as can be seen in the current implementation of json_dumper).
Proposed solution
- Create a new module in
save-analysis called external_data where the new *Data structs will live (they can be moved from json_dumper, along with the lowering code).
- Modify the
Dump trait to operate on save_analysis::external_data::* instead of on save_analysis::data::*.
Some open problems
When getting a DefId from a NodeId, what should we do when tcx.map.opt_local_def_id(node_id) returns None? What does that mean? If we call the function with a NodeId provided by the compiler, should it always succeed? The current code doesn't make that assumption (see data.rs)
Currently, the
Dumptrait exposes internal types of the compiler, which is undesirable. It also forces the trait's implementors to write lowering code (as can be seen in the current implementation ofjson_dumper).Proposed solution
save-analysiscalledexternal_datawhere the new*Datastructs will live (they can be moved fromjson_dumper, along with the lowering code).Dumptrait to operate onsave_analysis::external_data::*instead of onsave_analysis::data::*.Some open problems
When getting a
DefIdfrom aNodeId, what should we do whentcx.map.opt_local_def_id(node_id)returnsNone? What does that mean? If we call the function with aNodeIdprovided by the compiler, should it always succeed? The current code doesn't make that assumption (see data.rs)