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

Move rustc_hir::def_id to rustc_span::def_id #68718

Merged
merged 1 commit into from
Feb 9, 2020

Conversation

Aaron1011
Copy link
Member

This will allow HygieneData to refer to DefId and DefIndex, which
will enable proper serialization of Span hygiene information.

This also reduces the number of things imported from rustc_hir, which
might make it easier to remove dependencies on it.

@Aaron1011
Copy link
Member Author

This will break most tools - I'll submit follow-up PRs if this PR is merged.

@petrochenkov
Copy link
Contributor

This is pretty radical.

As I mentioned on discord, I'd prefer to have a proof-of-concept implementation of metadata encoding/decoding (using tables for translating between DefIds and ExpnIds) before making infrastructural changes like using DefId in ExpnId directly.

The proof-of-concept implementation can move def_id.rs to rustc_span if it turns out more convenient than the tables, but still reexport DefId from rustc_hir to avoid extensive changes until we are sure they are necessary.

@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 1, 2020
@bors
Copy link
Contributor

bors commented Feb 1, 2020

☔ The latest upstream changes (presumably #68133) made this pull request unmergeable. Please resolve the merge conflicts.

@Aaron1011
Copy link
Member Author

As I mentioned on discord, I'd prefer to have a proof-of-concept implementation of metadata encoding/decoding (using tables for translating between DefIds and ExpnIds) before making infrastructural changes like using DefId in ExpnId directly.

Wouldn't this effectively require importing the HygieneData of every dependency in our own HygieneData? If we want to convert a DefId into an ExpnId during deserialization, we need to import the corresponding ExpnData into our own HygieneData table, since an ExpnId has no concept of a 'source crate'.

This will result in each crate in the graph having a progressively larger HygieneData, with the last crate compiled having a HygieneData containing every single ExpnData every deserialized.

We could try to maintain a notion of 'local ExpnData' vs 'foreign ExpnData', and avoid re-serializing the ExpnData when it could be deserialized from an upstream crate. However, this seems much more complicated than just making ExpnIds proper 'def items', which could re-use the existing cstore_impl logic to handle data from other crates.

@petrochenkov
Copy link
Contributor

This will result in each crate in the graph having a progressively larger HygieneData, with the last crate compiled having a HygieneData containing every single ExpnData every deserialized.

Exactly.
That's ok and expected, that's how we build the first version that 1) is as simple as possible and can be built quickly, 2) is functionally correct, and 3) works and can be tested.
Then we write tests checking that cross-crate hygiene 2.0 works as expected and we actually got what we wanted.
After that we can start measuring the concrete numbers and perhaps thinking about optimizations.
That's my line of though at least.

@petrochenkov
Copy link
Contributor

@Aaron1011
Could you limit this PR to only moving the def_id.rs file and keeping a pub use in its previous place?

@Aaron1011
Copy link
Member Author

@petrochenkov: I ended up needing to make this change in #68941, so this PR may no longer be necessary.

@petrochenkov
Copy link
Contributor

@Aaron1011
I'm in process of reviewing #68941 and if moving def_id.rs is indeed a pre-requisite for it, then I'd prefer to land it here as a separate PR because it's mechanical and will make reviewing #68941 easier.

@Aaron1011
Copy link
Member Author

@petrochenkov: Updated

@petrochenkov
Copy link
Contributor

r=me with commits squashed.

For noww, librustc_hir re-exports the `def_id` module from
librustc_span, so the rest of rustc can continue to reference
rustc_hir::def_id
@Aaron1011
Copy link
Member Author

@petrochenkov: Squashed

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Feb 8, 2020

📌 Commit 619051e has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 8, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 8, 2020
…ochenkov

Move `rustc_hir::def_id` to `rustc_span::def_id`

This will allow `HygieneData` to refer to `DefId` and `DefIndex`, which
will enable proper serialization of Span hygiene information.

This also reduces the number of things imported from `rustc_hir`, which
might make it easier to remove dependencies on it.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 8, 2020
…ochenkov

Move `rustc_hir::def_id` to `rustc_span::def_id`

This will allow `HygieneData` to refer to `DefId` and `DefIndex`, which
will enable proper serialization of Span hygiene information.

This also reduces the number of things imported from `rustc_hir`, which
might make it easier to remove dependencies on it.
bors added a commit that referenced this pull request Feb 9, 2020
Rollup of 7 pull requests

Successful merges:

 - #68718 (Move `rustc_hir::def_id` to `rustc_span::def_id`)
 - #68834 (Fix and test implementation of BTreeMap's first/last_entry, pop_first/last)
 - #68857 (perf: Reduce Vec allocations in normalization by passing &mut Vec)
 - #68918 (Don't use the word "unwrap" to describe "unwrap" methods)
 - #68946 (Mark several functions and methods in core::cmp as #[must_use])
 - #68958 (Clean up E0277 and E0282 explanations)
 - #68960 (codegen: misc cleanups around debuginfo scopes and locations.)

Failed merges:

r? @ghost
bors added a commit that referenced this pull request Feb 9, 2020
Rollup of 7 pull requests

Successful merges:

 - #68718 (Move `rustc_hir::def_id` to `rustc_span::def_id`)
 - #68834 (Fix and test implementation of BTreeMap's first/last_entry, pop_first/last)
 - #68857 (perf: Reduce Vec allocations in normalization by passing &mut Vec)
 - #68918 (Don't use the word "unwrap" to describe "unwrap" methods)
 - #68946 (Mark several functions and methods in core::cmp as #[must_use])
 - #68958 (Clean up E0277 and E0282 explanations)
 - #68960 (codegen: misc cleanups around debuginfo scopes and locations.)

Failed merges:

r? @ghost
@bors bors merged commit 619051e into rust-lang:master Feb 9, 2020
bjorn3 added a commit to bjorn3/rust that referenced this pull request Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants