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

rustc_metadata: Some reorganization of the module structure #66056

Merged
merged 6 commits into from
Nov 8, 2019

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Nov 3, 2019

The new structure of rustc_metadata (or rather its parts affected by the refactoring) is

├── lib.rs
└── rmeta
    ├── decoder
    │   └── cstore_impl.rs
    ├── decoder.rs
    ├── encoder.rs
    ├── mod.rs
    └── table.rs

(schema is renamed to rmeta.)

The code inside rmeta is pretty self-contained, so we can now privatize almost everything in this module instead of using pub(crate) which was necessary when all these modules accessed their neighbors in the old flat structure.

encoder and decoder work with structures defined by rmeta.
table is a part of rmeta.
cstore_impl actively uses decoder methods and exposes their results through very few public methods (provide and _untracked methods).

r? @eddyb @spastorino

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 3, 2019
@petrochenkov petrochenkov force-pushed the metapriv branch 2 times, most recently from 3bbb889 to cf9cadd Compare November 3, 2019 15:49
@eddyb
Copy link
Member

eddyb commented Nov 3, 2019

I think I understand what the intent is, but I feel like "schema" stops making sense when it's more than just a bunch of type definitions.

I can think of two ways to improve on the naming (neither that great):

  • rename librustc_metadata to librustc_cross_crate and schema to metadata
  • or just rename schema to rmeta (on the basis that it's the "file format name")

I don't have a strong preference for having all the data types in their own module named schema (or if there is a good reason to do so, I've forgotten it), so your structure seems fine.

@petrochenkov
Copy link
Contributor Author

Forgot to cc the related PRs - #66001, #66024, #66028.

@bors
Copy link
Contributor

bors commented Nov 4, 2019

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

@petrochenkov
Copy link
Contributor Author

@eddyb
I've renamed schema to rmeta and moved it from rmeta.rs to rmeta/mod.rs.

@spastorino
Copy link
Member

Seems good to me. Leaving the final call to @eddyb

@@ -529,6 +528,6 @@ impl CrateStore for cstore::CStore {

fn metadata_encoding_version(&self) -> &[u8]
{
schema::METADATA_HEADER
rmeta::METADATA_HEADER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh I just noticed the name of the method is kind of out of sync with what it's actually returning. No need to change it now though.

@eddyb
Copy link
Member

eddyb commented Nov 5, 2019

@bors r+ This is great! 🎉

@bors
Copy link
Contributor

bors commented Nov 5, 2019

📌 Commit 62862c7b33189a3e50c53c4295f13867a09f6bdf has been approved by eddyb

@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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2019
@bors
Copy link
Contributor

bors commented Nov 6, 2019

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

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 6, 2019
@petrochenkov
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Nov 6, 2019

📌 Commit 684e4c5a9bf067f7926ec58d1e12c9a471b1e281 has been approved by eddyb

@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 Nov 6, 2019
bors added a commit that referenced this pull request Nov 7, 2019
Rollup of 5 pull requests

Successful merges:

 - #59789 (Revert two unapproved changes to rustc_typeck.)
 - #65752 (Use structured suggestions for missing associated items)
 - #65884 (syntax: ABI-oblivious grammar)
 - #65974 (A scheme for more macro-matcher friendly pre-expansion gating)
 - #66017 (Add future incompatibility lint for `array.into_iter()`)

Failed merges:

 - #66056 (rustc_metadata: Some reorganization of the module structure)

r? @ghost
@bors
Copy link
Contributor

bors commented Nov 7, 2019

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

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 7, 2019
@petrochenkov
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Nov 7, 2019

📌 Commit 5eb1cf1 has been approved by eddyb

@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 Nov 7, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 8, 2019
rustc_metadata: Some reorganization of the module structure

The new structure of `rustc_metadata` (or rather its parts affected by the refactoring) is
```
├── lib.rs
└── rmeta
    ├── decoder
    │   └── cstore_impl.rs
    ├── decoder.rs
    ├── encoder.rs
    ├── mod.rs
    └── table.rs
```

(`schema` is renamed to `rmeta`.)

The code inside `rmeta` is pretty self-contained, so we can now privatize almost everything in this module instead of using `pub(crate)`  which was necessary when all these modules accessed their neighbors in the old flat structure.

`encoder` and `decoder` work with structures defined by `rmeta`.
`table` is a part of `rmeta`.
`cstore_impl` actively uses decoder methods and exposes their results through very few public methods (`provide` and `_untracked` methods).

r? @eddyb @spastorino
bors added a commit that referenced this pull request Nov 8, 2019
Rollup of 8 pull requests

Successful merges:

 - #65554 (Enhance the documentation of BufReader for potential data loss)
 - #65580 (Add `MaybeUninit` methods `uninit_array`, `slice_get_ref`, `slice_get_mut`)
 - #66049 (consistent handling of missing sysroot spans)
 - #66056 (rustc_metadata: Some reorganization of the module structure)
 - #66123 (No more hidden elements)
 - #66157 (Improve math log documentation examples)
 - #66165 (Ignore these tests ,since the called commands doesn't exist in VxWorks)
 - #66190 (rustc_target: inline abi::FloatTy into abi::Primitive.)

Failed merges:

 - #66188 (`MethodSig` -> `FnSig` & Use it in `ItemKind::Fn`)

r? @ghost
@bors bors merged commit 5eb1cf1 into rust-lang:master Nov 8, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 20, 2019
rustc_metadata: Privatize more things

Continuation of rust-lang#66056.

The most notable change here is that `CrateMetadata` is moved from `cstore.rs` to `decoder.rs`.
Most of uses of `CrateMetadata` fields are in the decoder and uses of `root: CrateRoot` and other fields are so intertwined with each other that it would be hard to move a part of them into `cstore.rs` to privatize `CrateMetadata` fields, so we are going the other way round.

`cstore.rs` can probably be dismantled now, but I'll leave this to some other day.
Similarly, remaining `CrateMetadata` fields can be privatized by introducing some getter/setter methods, but not today.

r? @eddyb
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.

5 participants