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

Make reprs use a structured representation instead of a slice #39595

Merged
merged 2 commits into from Feb 9, 2017

Conversation

@camlorn
Copy link
Contributor

camlorn commented Feb 6, 2017

This is needed for -z reorder-fields. The old design uses a slice taken from HIR, plus a cache that lazily parses. The new design stores it directly in the AdtDef as a ReprOptions. We're doing this now because we need to be able to add reprs that don't necessarily exist in HIR for -z reorder-fields, but it needs to happen anyway.

lookup_repr_hints should be mostly deprecated. I want to remove it from layout before closing this, unless people think that should be a separate PR. The [WIP] is because of this. The problem with closing this as-is is that the code here isn't actually testable until some parts of the compiler start using it.

r? @eddyb

@camlorn camlorn force-pushed the camlorn:structured_repr branch from 26f340d to 272a3e5 Feb 6, 2017
@@ -1818,6 +1847,14 @@ impl<'tcx> TyS<'tcx> {
}
}
}


This comment has been minimized.

Copy link
@eddyb

eddyb Feb 6, 2017

Member

Extraneous empty line.

@@ -1818,6 +1847,14 @@ impl<'tcx> TyS<'tcx> {
}
}
}


pub fn get_repr(&self) -> Option<&ReprOptions> {

This comment has been minimized.

Copy link
@eddyb

eddyb Feb 6, 2017

Member

This is only used in encoder.rs, could it be a helper method there?

This comment has been minimized.

Copy link
@camlorn

camlorn Feb 6, 2017

Author Contributor

Yeah, it could. But my thought is that things like future lints are going to want it as well.

@@ -401,8 +401,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}
}

let repr_options = *self.tcx.item_type(adt_def_id).get_repr().expect(
&format!("{:?} is not an ADT", def_id)

This comment has been minimized.

Copy link
@eddyb

eddyb Feb 6, 2017

Member

Probably not the best to have this allocating here. If you make an encoding-specific helper method you can just use bug! in cases other than TyAdt.

This comment has been minimized.

Copy link
@camlorn

camlorn Feb 6, 2017

Author Contributor

I'll factor those out.

@camlorn
Copy link
Contributor Author

camlorn commented Feb 7, 2017

I've moved all of this to a helper method in encoder.rs for now. We can introduce something more general later if needed.

…utes. This effectively deprecates lookup_repr_hints.
@camlorn camlorn force-pushed the camlorn:structured_repr branch from 272a3e5 to 541aa8a Feb 7, 2017
@camlorn
Copy link
Contributor Author

camlorn commented Feb 7, 2017

Unless we want me to try to kill more lookup_repr_hints calls, I think this is at a mergable point. it should at least be sufficient for -z reorder-fields if nothing else.

if someone wants to suggest a large crate with a lot of tests that I can build really quickly to see if metadata is actually working, that's not necessarily a bad idea.

@eddyb
Copy link
Member

eddyb commented Feb 7, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Feb 7, 2017

📋 Looks like this PR is still in progress, ignoring approval

@eddyb eddyb changed the title [WIP] Make reprs use a structured representation instead of a slice Make reprs use a structured representation instead of a slice Feb 7, 2017
@eddyb
Copy link
Member

eddyb commented Feb 7, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Feb 7, 2017

📌 Commit c3b64cf has been approved by eddyb

bors added a commit that referenced this pull request Feb 8, 2017
bors added a commit that referenced this pull request Feb 8, 2017
bors added a commit that referenced this pull request Feb 8, 2017
Rollup of 6 pull requests

- Successful merges: #38165, #39456, #39587, #39589, #39598, #39641
- Failed merges: #39586, #39595
bors added a commit that referenced this pull request Feb 9, 2017
Rollup of 7 pull requests

- Successful merges: #37928, #39456, #39587, #39589, #39641, #39649, #39662
- Failed merges: #39586, #39595
bors added a commit that referenced this pull request Feb 9, 2017
Rollup of 7 pull requests

- Successful merges: #37928, #39456, #39587, #39589, #39641, #39649, #39662
- Failed merges: #39586, #39595
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 9, 2017
Make reprs use a structured representation instead of a slice

This is needed for `-z reorder-fields`.  The old design uses a slice taken from HIR, plus a cache that lazily parses.  The new design stores it directly in the `AdtDef` as a `ReprOptions`.  We're doing this now because we need to be able to add reprs that don't necessarily exist in HIR for `-z reorder-fields`, but it needs to happen anyway.

`lookup_repr_hints` should be mostly deprecated.  I want to remove it from `layout` before closing this, unless people think that should be a separate PR.  The `[WIP]` is because of this.  The problem with closing this as-is is that the code here isn't actually testable until some parts of the compiler start using it.

r? @eddyb
bors added a commit that referenced this pull request Feb 9, 2017
Rollup of 5 pull requests

- Successful merges: #39595, #39601, #39602, #39615, #39647
- Failed merges:
@bors bors merged commit c3b64cf into rust-lang:master Feb 9, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@camlorn camlorn deleted the camlorn:structured_repr branch Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.