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

Add rustc_abi::FieldIdx #606

Closed
2 of 3 tasks
scottmcm opened this issue Mar 26, 2023 · 3 comments
Closed
2 of 3 tasks

Add rustc_abi::FieldIdx #606

scottmcm opened this issue Mar 26, 2023 · 3 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@scottmcm
Copy link
Member

scottmcm commented Mar 26, 2023

Promote rustc_middle::mir::Field to rustc_abi::FieldIdx

Proposal

We have VariantIdx that's used broadly for source-order variants. mir::Field exists, but is not used pervasively -- it's basically just in projections.

This MCP proposes uplifting mir::Field to FieldIdx in rustc_abi, to be used in more places.

For example, FieldsShape::Arbitrary maps from "source order field indices", but are currently ordinary Vecs. With this change, offsets would become IndexVec<FieldIdx, Size> (instead of Vec<Size>).

Similarly, ty::VariantDef, despite being in the same crate as the existing mir::Field, holds a Vec<FieldDef>. After this MCP, that would move to IndexVec<FieldIdx, FieldDef>.

There are more as well, such as, CustomCoerceUnsized::Struct "Records the index of the field being coerced", but is currently storing a u32, and could move to FieldIdx.

Mentors or Reviewers

This is fairly straight-forward (but changes types enough to be worth an MCP, I thought) so I'm confident I can do it un-mentored.

I don't have any particular reviewer in mind.

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@scottmcm scottmcm added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Mar 26, 2023
@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2023

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Mar 26, 2023
@cjgillot
Copy link

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Mar 26, 2023
scottmcm added a commit to scottmcm/rust that referenced this issue Mar 29, 2023
The first PR for rust-lang/compiler-team#606

This is just the move-and-rename, because it's plenty big-and-bitrotty already.  Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 29, 2023
Move `mir::Field` → `abi::FieldIdx`

The first PR for rust-lang/compiler-team#606

This is just the move-and-rename, because it's plenty big already.  Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Mar 30, 2023
scottmcm added a commit to scottmcm/rust that referenced this issue Mar 30, 2023
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`.

There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places.

Part 2/? of rust-lang/compiler-team#606
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 31, 2023
…leLapkin

Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`

And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`.

There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places.

Part 2/? of rust-lang/compiler-team#606
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 31, 2023
Add `IndexSlice` to go with `IndexVec`

Moves the methods that don't need full `IndexVec`-ness over to `IndexSlice`, and have `IndexVec` deref to `IndexSlice` so everything keeps working.

Doing this for later use in rust-lang/compiler-team#606, where I'm hitting a bunch of things that are just slices and thus there's no way to index with the `FieldIdx`.
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 2, 2023
…-obk

Use `FieldIdx` in various things related to aggregates

Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.

Part 3/? of rust-lang/compiler-team#606

[`IndexSlice`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_index/vec/struct.IndexVec.html#deref-methods-IndexSlice%3CI,+T%3E) was added in rust-lang#109787
oli-obk pushed a commit to oli-obk/miri that referenced this issue Apr 4, 2023
Add `IndexSlice` to go with `IndexVec`

Moves the methods that don't need full `IndexVec`-ness over to `IndexSlice`, and have `IndexVec` deref to `IndexSlice` so everything keeps working.

Doing this for later use in rust-lang/compiler-team#606, where I'm hitting a bunch of things that are just slices and thus there's no way to index with the `FieldIdx`.
@scottmcm
Copy link
Member Author

scottmcm commented Apr 5, 2023

It's been 10 days since the second, so I'm closing this as approved. (And in fact work is already in-progress towards it.)

@scottmcm scottmcm closed this as completed Apr 5, 2023
@WaffleLapkin WaffleLapkin added major-change-accepted A major change proposal that was accepted and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Apr 5, 2023
@rustbot rustbot added the to-announce Announce this issue on triage meeting label Apr 5, 2023
@WaffleLapkin WaffleLapkin removed the to-announce Announce this issue on triage meeting label Apr 5, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 6, 2023
Use `FieldIdx` in `FieldsShape`

Finally got to the main motivating example from rust-lang/compiler-team#606 :)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this issue Apr 9, 2023
The first PR for rust-lang/compiler-team#606

This is just the move-and-rename, because it's plenty big-and-bitrotty already.  Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this issue Apr 9, 2023
Move `mir::Field` → `abi::FieldIdx`

The first PR for rust-lang/compiler-team#606

This is just the move-and-rename, because it's plenty big already.  Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this issue Apr 9, 2023
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`.

There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places.

Part 2/? of rust-lang/compiler-team#606
saethlin pushed a commit to saethlin/miri that referenced this issue Apr 10, 2023
Use `FieldIdx` in `FieldsShape`

Finally got to the main motivating example from rust-lang/compiler-team#606 :)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 17, 2023
Various minor Idx-related tweaks

Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.

cc rust-lang/compiler-team#606
r? `@WaffleLapkin`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

5 participants