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

rustc_mir_transform cleanups 3 #130175

Merged
merged 8 commits into from
Sep 10, 2024

Conversation

nnethercote
Copy link
Contributor

More cleanups in the style of #129929.

r? @saethlin

By reflowing comment lines that are too long, and a few that are very
short. Plus some other very minor formatting tweaks.
These are all functions with a single callsite, where having a separate
function does nothing to help with readability. These changes make the
code a little shorter and easier to read.
The "as" is equivalent to "because", but I originally read it more like
"when", which was confusing.
This was non-obvious to me.
In all cases the struct can own the relevant thing instead of having a
reference to it. This makes the code simpler, and in some cases removes
a struct lifetime.
It's a thin wrapper around `check_live_drops`, but it's enough to fix
the FIXME comment.
@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in coverage instrumentation.

cc @Zalathar

@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 Sep 9, 2024
Comment on lines +134 to +136
// need to also add a retag statement. *Except* if we are deref'ing a
// Box, because those get desugared to directly working with the inner
// raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it
Copy link
Member

Choose a reason for hiding this comment

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

My kingdom for a code review tool that can ignore this diff

// Clone dominators because we need them while mutating the body.
let dominators = body.basic_blocks.dominators().clone();

let mut state = VnState::new(tcx, body, param_env, &ssa, dominators, &body.local_decls);
Copy link
Member

Choose a reason for hiding this comment

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

What happened here? How did rustfmt let the original code be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see what's wrong with the original code...

Copy link
Member

Choose a reason for hiding this comment

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

Upon further inspection, I don't either. The way "remove whitespace" displayed this part of the diff confused me.

None,
);
check_consts::post_drop_elaboration::check_live_drops(tcx, body); // FIXME: make this a MIR lint
Copy link
Member

Choose a reason for hiding this comment

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

pm::run_passes has a bit of extra logic in it for running MIR linting/validation as well as -Zmir-enable-passes. So this isn't necessarily a no-op, but I'm down with following the FIXME.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is just a comment, not a request for a change, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. Just a comment.

@saethlin
Copy link
Member

saethlin commented Sep 10, 2024

I have a question (and two comments, such as they are) ^
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2024
Comment on lines +140 to +141
// A move out of a projection of a copy is equivalent to a copy of the original
// projection.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: These single-word reflows are a bit awkward.

For single-line comments that don't quite fit in 100 columns, I'd consider breaking them even earlier (closer to 80 columns) just so that the second line is a bit longer.

(But if you're using automation to do this then maybe it's not worth the extra effort. 🤷‍♂️)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just reflowed them all to width 100, because that's the closest I could get to the original while observing the "don't exceed 100 chars" rule. I definitely don't want to be thinking about different widths for different comments depending on their contents. One word on a line by itself is fine.

@fmease fmease changed the title rustc_mir_transformcleanups 3 rustc_mir_transform cleanups 3 Sep 10, 2024
@saethlin
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 10, 2024

📌 Commit 8949b44 has been approved by saethlin

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 10, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 10, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#130143 (miri-test-libstd: add missing BOOTSTRAP_ARGS)
 - rust-lang#130173 (rustdoc: add two regression tests)
 - rust-lang#130175 (`rustc_mir_transform` cleanups 3)
 - rust-lang#130184 (coverage: Clean up terminology in counter creation)
 - rust-lang#130185 (abi/compatibility test: remove tests inside repr(C) wrappers)

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

Rollup of 5 pull requests

Successful merges:

 - rust-lang#130143 (miri-test-libstd: add missing BOOTSTRAP_ARGS)
 - rust-lang#130173 (rustdoc: add two regression tests)
 - rust-lang#130175 (`rustc_mir_transform` cleanups 3)
 - rust-lang#130184 (coverage: Clean up terminology in counter creation)
 - rust-lang#130185 (abi/compatibility test: remove tests inside repr(C) wrappers)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit accd77e into rust-lang:master Sep 10, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 10, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 10, 2024
Rollup merge of rust-lang#130175 - nnethercote:rustc_mir_transform-cleanups-3, r=saethlin

`rustc_mir_transform` cleanups 3

More cleanups in the style of rust-lang#129929.

r? `@saethlin`
@nnethercote nnethercote deleted the rustc_mir_transform-cleanups-3 branch September 11, 2024 06:19
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