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

MIR building: Stop using unpack! for BlockAnd<()> #127472

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Jul 8, 2024

This is a subset of #127416, containing only the parts related to BlockAnd<()>.

The first patch removes the non-assigning form of the unpack! macro, because it is frustratingly inconsistent with the main form. We can replace it with an ordinary method that discards the () and returns the block.

The second patch then finds all of the remaining code that was using unpack! with BlockAnd<()>, and updates it to use that new method instead.


Changes since original review of #127416:

  • Renamed fn unpack_blockfn into_block
  • Removed fn unpack_discard, replacing it with let _: BlockAnd<()> = ... (2 occurrences)
  • Tweaked arm_end_blocks to unpack earlier and build Vec<BasicBlock> instead of Vec<BlockAnd<()>>

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 8, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jul 8, 2024

Some changes occurred in match lowering

cc @Nadrieril

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

I have a suggestion which you don't necessarily need to take to heart.

r=fmease,Nadrieril if Nadrieril approves as well

compiler/rustc_mir_build/src/build/mod.rs Outdated Show resolved Hide resolved
This kind of unpacking can be expressed as an ordinary method on
`BlockAnd<()>`.
@Zalathar
Copy link
Contributor Author

Zalathar commented Jul 8, 2024

Renamed fn unpack_block_and_unitfn into_block (diff).

@fmease
Copy link
Member

fmease commented Jul 17, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 17, 2024

📌 Commit 1cf4eb2 has been approved by fmease

It is now in the queue for this repository.

@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 Jul 17, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#125042 (Use ordinal number in argument error)
 - rust-lang#127229 (rustdoc: click target for sidebar items flush left)
 - rust-lang#127337 (Move a few intrinsics to Rust abi)
 - rust-lang#127472 (MIR building: Stop using `unpack!` for `BlockAnd<()>`)
 - rust-lang#127579 (Solve a error `.clone()` suggestion when moving a mutable reference)
 - rust-lang#127769 (Don't use implicit features in `Cargo.toml` in `compiler/`)
 - rust-lang#127844 (Remove invalid further restricting suggestion for type bound)
 - rust-lang#127855 (Add myself to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#125042 (Use ordinal number in argument error)
 - rust-lang#127229 (rustdoc: click target for sidebar items flush left)
 - rust-lang#127337 (Move a few intrinsics to Rust abi)
 - rust-lang#127472 (MIR building: Stop using `unpack!` for `BlockAnd<()>`)
 - rust-lang#127579 (Solve a error `.clone()` suggestion when moving a mutable reference)
 - rust-lang#127769 (Don't use implicit features in `Cargo.toml` in `compiler/`)
 - rust-lang#127844 (Remove invalid further restricting suggestion for type bound)
 - rust-lang#127855 (Add myself to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#125042 (Use ordinal number in argument error)
 - rust-lang#127229 (rustdoc: click target for sidebar items flush left)
 - rust-lang#127337 (Move a few intrinsics to Rust abi)
 - rust-lang#127472 (MIR building: Stop using `unpack!` for `BlockAnd<()>`)
 - rust-lang#127579 (Solve a error `.clone()` suggestion when moving a mutable reference)
 - rust-lang#127769 (Don't use implicit features in `Cargo.toml` in `compiler/`)
 - rust-lang#127844 (Remove invalid further restricting suggestion for type bound)
 - rust-lang#127855 (Add myself to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c98487e into rust-lang:master Jul 18, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
Rollup merge of rust-lang#127472 - Zalathar:block-and-unit, r=fmease

MIR building: Stop using `unpack!` for `BlockAnd<()>`

This is a subset of rust-lang#127416, containing only the parts related to `BlockAnd<()>`.

The first patch removes the non-assigning form of the `unpack!` macro, because it is frustratingly inconsistent with the main form. We can replace it with an ordinary method that discards the `()` and returns the block.

The second patch then finds all of the remaining code that was using `unpack!` with `BlockAnd<()>`, and updates it to use that new method instead.

---

Changes since original review of rust-lang#127416:
- Renamed `fn unpack_block` → `fn into_block`
- Removed `fn unpack_discard`, replacing it with `let _: BlockAnd<()> = ...` (2 occurrences)
- Tweaked `arm_end_blocks` to unpack earlier and build `Vec<BasicBlock>` instead of `Vec<BlockAnd<()>>`
@Zalathar Zalathar deleted the block-and-unit branch July 18, 2024 01:40
@Nadrieril
Copy link
Member

Whoops I hadn't seen that you were waiting for me. LGTM, thx for merging 👍

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants