compiler: Don't mark SingleUseConsts MIR pass as "required for soundness"#152729
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Feb 18, 2026
Merged
Conversation
Collaborator
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Collaborator
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
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.
ef294be to
52b19f7
Compare
Contributor
|
@bors r+ |
Contributor
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-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I don't think this MIR pass is required for soundness. The reasons are:
SingleUseConsts(see AddSingleUseConstsmir-opt pass #125910 for the switch).#[optimize(none)]#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0.MirPass::can_be_overridden()is unchanged and thus returnstrue, indicating that it is not a required MIR pass.mir_opt_level > 1forSingleUseConstsMIR pass #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.