Skip to content

Conversation

nnethercote
Copy link
Contributor

I found two modules in other crates that are better placed in rustc_mir_transform, because that's the only crate that uses them.

r? @matthewjasper

`rustc_mir_dataflow/src/elaborate_drops.rs` contains some infrastructure
used by a few MIR passes: the `elaborate_drop` function, the
`DropElaborator` trait, etc.

`rustc_mir_transform/src/elaborate_drops.rs` (same file name, different
crate) contains the `ElaborateDrops` pass. It relies on a lot of the
infrastructure from `rustc_mir_dataflow/src/elaborate_drops.rs`.

It turns out that the drop infrastructure is only used in
`rustc_mir_transform`, so this commit moves it there. (The only
exception is the small `DropFlagState` type, which is moved to the
existing `rustc_mir_dataflow/src/drop_flag_effects.rs`.) The file is
renamed from `rustc_mir_dataflow/src/elaborate_drops.rs` to
`rustc_mir_transform/src/elaborate_drop.rs` (with no trailing `s`)
because (a) the `elaborate_drop` function is the most important export,
and (b) `rustc_mir_transform/src/elaborate_drops.rs` already exists.

All the infrastructure pieces that used to be `pub` are now
`pub(crate)`, because they are now only used within
`rustc_mir_transform`.
Because it's only used in `rustc_mir_transform`. (Presumably it is
currently in `rustc_middle` because lots of other MIR-related stuff is,
but that's not a hard requirement.) And because `rustc_middle` is huge
and it's always good to make it smaller.
@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 Feb 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@workingjubilee
Copy link
Member

oh cool, we actually did finally get all of rustc_const_eval::transform out of rustc_const_eval at some point. nice job!

@oli-obk
Copy link
Contributor

oli-obk commented Feb 14, 2025

r? @oli-obk

@bors r+

@bors
Copy link
Collaborator

bors commented Feb 14, 2025

📌 Commit 28b75a3 has been approved by oli-obk

It is now in the queue for this repository.

@rustbot rustbot assigned oli-obk and unassigned matthewjasper Feb 14, 2025
@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 Feb 14, 2025
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Feb 14, 2025
…_transform, r=oli-obk

Move code into `rustc_mir_transform`

I found two modules in other crates that are better placed in `rustc_mir_transform`, because that's the only crate that uses them.

r? `@matthewjasper`
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 14, 2025
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#135778 (account for `c_enum_min_bits` in `multiple-reprs` UI test)
 - rust-lang#136052 (Correct comment for FreeBSD and DragonFly BSD in unix/thread)
 - rust-lang#136886 (Remove the common prelude module)
 - rust-lang#136938 (Remove `:` from `stack-protector-heuristics-effect.rs` Filecheck Pattern)
 - rust-lang#136956 (add vendor directory to .gitignore)
 - rust-lang#136958 (Fix presentation of purely "additive" replacement suggestion parts)
 - rust-lang#136967 (Use `slice::fill` in `io::Repeat` implementation)
 - rust-lang#136976 (alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr)
 - rust-lang#137007 (Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand`)
 - rust-lang#137008 (Move code into `rustc_mir_transform`)

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

Rollup of 9 pull requests

Successful merges:

 - rust-lang#135778 (account for `c_enum_min_bits` in `multiple-reprs` UI test)
 - rust-lang#136052 (Correct comment for FreeBSD and DragonFly BSD in unix/thread)
 - rust-lang#136886 (Remove the common prelude module)
 - rust-lang#136956 (add vendor directory to .gitignore)
 - rust-lang#136958 (Fix presentation of purely "additive" replacement suggestion parts)
 - rust-lang#136967 (Use `slice::fill` in `io::Repeat` implementation)
 - rust-lang#136976 (alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr)
 - rust-lang#137007 (Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand`)
 - rust-lang#137008 (Move code into `rustc_mir_transform`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit bd094fb into rust-lang:master Feb 14, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 14, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 14, 2025
Rollup merge of rust-lang#137008 - nnethercote:mv-code-into-rustc_mir_transform, r=oli-obk

Move code into `rustc_mir_transform`

I found two modules in other crates that are better placed in `rustc_mir_transform`, because that's the only crate that uses them.

r? ``@matthewjasper``
@marxin
Copy link
Contributor

marxin commented Feb 16, 2025

Please, reflect the change in rustc-dev-guide:

error: Server returned 404 Not Found for https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_dataflow/src/elaborate_drops.rs
    ┌─ mir/drop-elaboration.md:128:52
    │
128 │ itself is defined [here][drops-transform], but the [main logic][drops] is
    │                                                    ^^^^^^^^^^^^^^^^^^^ Server returned 404 Not Found for https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_dataflow/src/elaborate_drops.rs

@nnethercote nnethercote deleted the mv-code-into-rustc_mir_transform branch February 16, 2025 21:42
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.

7 participants