Skip to content

compiler: Don't mark SingleUseConsts MIR pass as "required for soundness"#152729

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Enselic:single_use_consts-not-required
Feb 18, 2026
Merged

compiler: Don't mark SingleUseConsts MIR pass as "required for soundness"#152729
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Enselic:single_use_consts-not-required

Conversation

@Enselic
Copy link
Member

@Enselic Enselic commented Feb 16, 2026

I don't think this MIR pass is required for soundness. The reasons are:

As shown in the updated test tests/mir-opt/optimize_none.rs, #[optimize(none)] functions become even less optimized, as expected and desired.

Unblocks #151426.

@rustbot
Copy link
Collaborator

rustbot commented Feb 16, 2026

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 16, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 16, 2026

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, mir, mir-opt
  • compiler, mir, mir-opt expanded to 68 candidates
  • Random selection from 14 candidates

@rust-log-analyzer

This comment has been minimized.

…dness"

Because:
* Something like it did not exist before PR 107404
* That it is not run our mir-opt-level 0 indicates that it is not
  required for soundness
* Its `MirPass::can_be_overridden()` is unchanged and thus returns true,
  indicating that it is not a required MIR pass.
* No test fails in PR 151426 that stops enabling by default in non-optimized builds

As can be seen from the updated test `tests/mir-opt/optimize_none.rs`,
this means that `#[optimize(none)]` functions become even less
optimized. As expected and as desired.
@Enselic Enselic force-pushed the single_use_consts-not-required branch from ef294be to 52b19f7 Compare February 17, 2026 05:22
@cjgillot
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 17, 2026

📌 Commit 52b19f7 has been approved by cjgillot

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 17, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 18, 2026
…ired, r=cjgillot

compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness"

I don't think this MIR pass is required for soundness. The reasons are:
* Something like it was not enabled by default before PR rust-lang#107404 which was the precursor to `SingleUseConsts` (see rust-lang#125910 for the switch).
* By following the advice from rust-lang#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0.
* Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass.
* PR CI pass in rust-lang#151426 which stops enabling it by default in non-optimized builds.

As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired.

Unblocks rust-lang#151426.
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 18, 2026
…ired, r=cjgillot

compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness"

I don't think this MIR pass is required for soundness. The reasons are:
* Something like it was not enabled by default before PR rust-lang#107404 which was the precursor to `SingleUseConsts` (see rust-lang#125910 for the switch).
* By following the advice from rust-lang#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0.
* Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass.
* PR CI pass in rust-lang#151426 which stops enabling it by default in non-optimized builds.

As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired.

Unblocks rust-lang#151426.
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 18, 2026
…ired, r=cjgillot

compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness"

I don't think this MIR pass is required for soundness. The reasons are:
* Something like it was not enabled by default before PR rust-lang#107404 which was the precursor to `SingleUseConsts` (see rust-lang#125910 for the switch).
* By following the advice from rust-lang#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0.
* Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass.
* PR CI pass in rust-lang#151426 which stops enabling it by default in non-optimized builds.

As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired.

Unblocks rust-lang#151426.
rust-bors bot pushed a commit that referenced this pull request Feb 18, 2026
Rollup of 19 pull requests

Successful merges:

 - #145399 (Unify wording of resolve error)
 - #150473 (tail calls: fix copying non-scalar arguments to callee)
 - #152637 (Add a note about elided lifetime)
 - #152657 (std: move `exit` out of PAL)
 - #152729 (compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness")
 - #152753 (remove the explicit error for old `rental` versions)
 - #152758 (Remove ShallowInitBox.)
 - #151530 (Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error)
 - #152179 (Add documentation note about signed overflow direction)
 - #152474 (Implement opt-bisect-limit for MIR)
 - #152509 (tests/ui/test-attrs: add annotations for reference rules)
 - #152672 (std: use libc version of `_NSGetArgc`/`_NSGetArgv`)
 - #152711 (resolve: Disable an assert that no longer holds)
 - #152732 (add regression test for 147958)
 - #152745 (Fix ICE in `suggest_param_env_shadowing` with incompatible args)
 - #152749 (make `rustc_allow_const_fn_unstable` an actual `rustc_attrs` attribute)
 - #152756 (Miri: recursive validity: also recurse into Boxes)
 - #152770 (carryless_mul: mention the base)
 - #152778 (Update tracking issue number for final_associated_functions)
rust-bors bot pushed a commit that referenced this pull request Feb 18, 2026
Rollup of 20 pull requests

Successful merges:

 - #145399 (Unify wording of resolve error)
 - #150473 (tail calls: fix copying non-scalar arguments to callee)
 - #152637 (Add a note about elided lifetime)
 - #152729 (compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness")
 - #152751 (Rename dep node "fingerprints" to distinguish key and value hashes)
 - #152753 (remove the explicit error for old `rental` versions)
 - #152758 (Remove ShallowInitBox.)
 - #151530 (Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error)
 - #152179 (Add documentation note about signed overflow direction)
 - #152474 (Implement opt-bisect-limit for MIR)
 - #152509 (tests/ui/test-attrs: add annotations for reference rules)
 - #152672 (std: use libc version of `_NSGetArgc`/`_NSGetArgv`)
 - #152711 (resolve: Disable an assert that no longer holds)
 - #152725 (Rework explanation of CLI lint level flags)
 - #152732 (add regression test for 147958)
 - #152745 (Fix ICE in `suggest_param_env_shadowing` with incompatible args)
 - #152749 (make `rustc_allow_const_fn_unstable` an actual `rustc_attrs` attribute)
 - #152756 (Miri: recursive validity: also recurse into Boxes)
 - #152770 (carryless_mul: mention the base)
 - #152778 (Update tracking issue number for final_associated_functions)
@rust-bors rust-bors bot merged commit dbc2193 into rust-lang:main Feb 18, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 18, 2026
rust-timer added a commit that referenced this pull request Feb 18, 2026
Rollup merge of #152729 - Enselic:single_use_consts-not-required, r=cjgillot

compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness"

I don't think this MIR pass is required for soundness. The reasons are:
* Something like it was not enabled by default before PR #107404 which was the precursor to `SingleUseConsts` (see #125910 for the switch).
* By following the advice from #128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0.
* Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass.
* PR CI pass in #151426 which stops enabling it by default in non-optimized builds.

As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired.

Unblocks #151426.
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

Comments