Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save-analysis: use a decoupled representation for dumped data #33348

Closed
aochagavia opened this issue May 2, 2016 · 2 comments
Closed

save-analysis: use a decoupled representation for dumped data #33348

aochagavia opened this issue May 2, 2016 · 2 comments

Comments

@aochagavia
Copy link
Contributor

aochagavia commented May 2, 2016

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

  1. 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).
  2. 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)

@aochagavia
Copy link
Contributor Author

aochagavia commented May 2, 2016

cc @nrc

Do you know the answer to my questions in the open problems part?

@nrc
Copy link
Member

nrc commented May 2, 2016

@aochagavia if the def id is from the local crate, then it should never return None. I think we can assume that and just unwrap. We do need to make sure we only call with local ids though, it is possible we could get a NodeId from an extern crate (via metadata or something?).

Manishearth added a commit to Manishearth/rust that referenced this issue May 9, 2016
save-analysis: use a decoupled representation for dumped data

Closes rust-lang#33348

This will probably break any tool relying on the csv backend of save_analysis, for the following reasons:

1. Dumped spans don't contain extents anymore (`Dump` uses `SpanData` now instead of internal `Span`s). In case we still want to dump extents we could add them to `SpanData`.
1. `DefId`s are no longer dumped as a pair of `(ref_id, ref_crate)`. Instead, they are dumped as a single `Id`.

@nrc You said something about storing the id in a `u64`, but you didn't explain why. I kept using `u32` in this branch but I can change it if you prefer that.

r? @nrc

By the way, the fact that this breaks tools relying on CSV may be a good occasion to start dumping CSV in a different way (i.e. using the serializer like in the JSON backend).
Manishearth added a commit to Manishearth/rust that referenced this issue May 9, 2016
save-analysis: use a decoupled representation for dumped data

Closes rust-lang#33348

This will probably break any tool relying on the csv backend of save_analysis, for the following reasons:

1. Dumped spans don't contain extents anymore (`Dump` uses `SpanData` now instead of internal `Span`s). In case we still want to dump extents we could add them to `SpanData`.
1. `DefId`s are no longer dumped as a pair of `(ref_id, ref_crate)`. Instead, they are dumped as a single `Id`.

@nrc You said something about storing the id in a `u64`, but you didn't explain why. I kept using `u32` in this branch but I can change it if you prefer that.

r? @nrc

By the way, the fact that this breaks tools relying on CSV may be a good occasion to start dumping CSV in a different way (i.e. using the serializer like in the JSON backend).
Manishearth added a commit to Manishearth/rust that referenced this issue May 9, 2016
save-analysis: use a decoupled representation for dumped data

Closes rust-lang#33348

This will probably break any tool relying on the csv backend of save_analysis, for the following reasons:

1. Dumped spans don't contain extents anymore (`Dump` uses `SpanData` now instead of internal `Span`s). In case we still want to dump extents we could add them to `SpanData`.
1. `DefId`s are no longer dumped as a pair of `(ref_id, ref_crate)`. Instead, they are dumped as a single `Id`.

@nrc You said something about storing the id in a `u64`, but you didn't explain why. I kept using `u32` in this branch but I can change it if you prefer that.

r? @nrc

By the way, the fact that this breaks tools relying on CSV may be a good occasion to start dumping CSV in a different way (i.e. using the serializer like in the JSON backend).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants