Skip to content

Add fn on types for layout of variants #75552

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

Closed
wants to merge 1 commit into from

Conversation

JulianKnodt
Copy link
Contributor

@JulianKnodt JulianKnodt commented Aug 15, 2020

This creates a query(I believe?) for the variants of types, which can later be used in #54360.
Edit: Looking at this again, I'm not particularly sure how to connect the query system & the actual function call.
2nd Edit: I realize that I'm missing a call to modify the Providers struct, but I'm not quite sure where to put it. As well, I'm not sure if this is even necessary because I can return an iterator to the layouts of each of the variants, which also contains a size field which is good enough for my use case.

This just creates a function on type which returns an iterator of reference to the layouts of the types.

I have no idea who to request for review here, and/or what about this PR should watch out for.

@rust-highfive
Copy link
Contributor

r? @davidtwco

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 15, 2020
@JulianKnodt JulianKnodt changed the title Add query for layout of variants of types Add fn on types for layout of variants Aug 15, 2020
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

This seems fine to me but I'm not sure what the context is - do you intend to use this function somewhere (in which case, you can probably just include this as a commit in the PR which uses it)? is there an issue/discussion where the need for this was discussed?

@@ -884,6 +884,7 @@ rustc_queries! {
query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
desc { "computing whether `{}` is `Sized`", env.value }
}
Copy link
Member

Choose a reason for hiding this comment

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

Here's the chapter on the rustc-dev-guide on adding queries - try grepping for an existing query (e.g. unused_generic_params since I know that one isn't used in many places) and copy the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah you're probably right, I do want to add this with what I want to end up doing, so for now I'll hold off. I'll try replicating that query when I do so, as the other one I was replicating was scattered all about and hard to follow.

@JulianKnodt JulianKnodt marked this pull request as draft August 17, 2020 00:37
@JulianKnodt
Copy link
Contributor Author

r? @ghost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants