Skip to content

Conversation

@cjgillot
Copy link
Contributor

Rebase of #101500

Fixes #51003.

The first commit moves detection of uninhabited types from the current liveness pass to MIR building.

In order to keep the same level of diagnostics, I had to instrument MIR a little more:

  • keep for which original local a guard local is created;
  • store in the VarBindingForm the list of introducer places and whether this was a shorthand pattern.

I am not very proud of the handling of self-assignments. The proposed scheme is in two parts: first detect probable self-assignments, by pattern matching on MIR, and second treat them specially during dataflow analysis. I welcome ideas.

Please review carefully the changes in tests. There are many small changes to behaviour, and I'm not sure all of them are desirable.

@rustbot
Copy link
Collaborator

rustbot commented Jun 12, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
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

@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 Jun 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 12, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

Some changes occurred in match lowering

cc @Nadrieril

Some changes occurred in match checking

cc @Nadrieril

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 12, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 13, 2025

⌛ Trying commit 1d8df21 with merge 50ba7f2

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 13, 2025
Perform unused assignment and unused variables lints on MIR.

Rebase of #101500

Fixes #51003.

The first commit moves detection of uninhabited types from the current liveness pass to MIR building.

In order to keep the same level of diagnostics, I had to instrument MIR a little more:
- keep for which original local a guard local is created;
- store in the `VarBindingForm` the list of introducer places and whether this was a shorthand pattern.

I am not very proud of the handling of self-assignments. The proposed scheme is in two parts: first detect probable self-assignments, by pattern matching on MIR, and second treat them specially during dataflow analysis. I welcome ideas.

Please review carefully the changes in tests. There are many small changes to behaviour, and I'm not sure all of them are desirable.

<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 13, 2025
bors added a commit that referenced this pull request Jun 13, 2025
Perform unused assignment and unused variables lints on MIR.

Rebase of #101500

Fixes #51003.

The first commit moves detection of uninhabited types from the current liveness pass to MIR building.

In order to keep the same level of diagnostics, I had to instrument MIR a little more:
- keep for which original local a guard local is created;
- store in the `VarBindingForm` the list of introducer places and whether this was a shorthand pattern.

I am not very proud of the handling of self-assignments. The proposed scheme is in two parts: first detect probable self-assignments, by pattern matching on MIR, and second treat them specially during dataflow analysis. I welcome ideas.

Please review carefully the changes in tests. There are many small changes to behaviour, and I'm not sure all of them are desirable.
@bors
Copy link
Collaborator

bors commented Jun 13, 2025

⌛ Trying commit 1d8df21 with merge b0d7157...

@rust-bors
Copy link

rust-bors bot commented Jun 13, 2025

☀️ Try build successful (CI)
Build commit: 50ba7f2 (50ba7f2d41092ac03e7b2d705a93e2e3e56bbf24, parent: 573a01569000d395498a5f98f916d6e5305ac81a)

@rust-timer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jun 13, 2025

☀️ Try build successful - checks-actions
Build commit: b0d7157 (b0d7157996aa3b283f7f26ec09fc81c1612b5fce)

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (50ba7f2): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.6% [0.2%, 1.4%] 65
Regressions ❌
(secondary)
0.7% [0.2%, 2.8%] 103
Improvements ✅
(primary)
-0.5% [-0.6%, -0.5%] 2
Improvements ✅
(secondary)
-0.4% [-0.7%, -0.3%] 22
All ❌✅ (primary) 0.6% [-0.6%, 1.4%] 67

Max RSS (memory usage)

Results (primary 0.8%, secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.6% [1.0%, 2.9%] 12
Regressions ❌
(secondary)
2.5% [0.7%, 9.0%] 14
Improvements ✅
(primary)
-4.2% [-7.0%, -1.4%] 2
Improvements ✅
(secondary)
-6.2% [-10.9%, -2.3%] 5
All ❌✅ (primary) 0.8% [-7.0%, 2.9%] 14

Cycles

Results (primary 1.3%, secondary 3.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.3% [0.9%, 1.7%] 14
Regressions ❌
(secondary)
3.2% [2.4%, 4.4%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.3% [0.9%, 1.7%] 14

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 754.801s -> 755.907s (0.15%)
Artifact size: 372.21 MiB -> 372.18 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 13, 2025
rust-bors bot added a commit that referenced this pull request Jun 15, 2025
Pre-compute MIR CFG caches for borrowck and other analyses

I was puzzled that #142390 introduces additional computations of CFG traversals: borrowck computes them, right?

It turns out that borrowck clones the MIR body, so doesn't share its cache with other analyses.

This PR:
- forces the computation of all caches in `mir_promoted` query;
- modifies region renumbering to avoid dropping that cache.

<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->
@bors
Copy link
Collaborator

bors commented Oct 12, 2025

⌛ Testing commit be46a90 with merge ff6dc92...

@bors
Copy link
Collaborator

bors commented Oct 12, 2025

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing ff6dc92 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 12, 2025
@bors bors merged commit ff6dc92 into rust-lang:master Oct 12, 2025
12 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 12, 2025
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 8927649 (parent) -> ff6dc92 (this PR)

Test differences

Show 376 test diffs

Stage 0

  • errors::verify_mir_build_bindings_with_variant_name_10: pass -> [missing] (J1)
  • errors::verify_mir_build_bindings_with_variant_name_11: [missing] -> pass (J1)
  • errors::verify_mir_build_borrow_of_moved_value_16: [missing] -> pass (J1)
  • errors::verify_mir_build_const_continue_bad_const_31: pass -> [missing] (J1)
  • errors::verify_mir_build_const_continue_bad_const_32: [missing] -> pass (J1)
  • errors::verify_mir_build_const_continue_missing_label_or_value_32: pass -> [missing] (J1)
  • errors::verify_mir_build_const_continue_unknown_jump_target_34: [missing] -> pass (J1)
  • errors::verify_mir_build_const_pattern_depends_on_generic_parameter_3: pass -> [missing] (J1)
  • errors::verify_mir_build_const_pattern_depends_on_generic_parameter_4: [missing] -> pass (J1)
  • errors::verify_mir_build_could_not_eval_const_pattern_5: [missing] -> pass (J1)
  • errors::verify_mir_build_invalid_pattern_20: [missing] -> pass (J1)
  • errors::verify_mir_build_irrefutable_let_patterns_if_let_11: pass -> [missing] (J1)
  • errors::verify_mir_build_irrefutable_let_patterns_if_let_guard_12: pass -> [missing] (J1)
  • errors::verify_mir_build_irrefutable_let_patterns_while_let_14: pass -> [missing] (J1)
  • errors::verify_mir_build_irrefutable_let_patterns_while_let_15: [missing] -> pass (J1)
  • errors::verify_mir_build_leading_irrefutable_let_patterns_8: pass -> [missing] (J1)
  • errors::verify_mir_build_leading_irrefutable_let_patterns_9: [missing] -> pass (J1)
  • errors::verify_mir_build_loop_match_bad_rhs_28: pass -> [missing] (J1)
  • errors::verify_mir_build_loop_match_bad_rhs_29: [missing] -> pass (J1)
  • errors::verify_mir_build_loop_match_bad_statements_28: [missing] -> pass (J1)
  • errors::verify_mir_build_loop_match_invalid_update_24: pass -> [missing] (J1)
  • errors::verify_mir_build_loop_match_invalid_update_25: [missing] -> pass (J1)
  • errors::verify_mir_build_loop_match_missing_assignment_29: pass -> [missing] (J1)
  • errors::verify_mir_build_loop_match_missing_assignment_30: [missing] -> pass (J1)
  • errors::verify_mir_build_loop_match_unsupported_type_26: pass -> [missing] (J1)
  • errors::verify_mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper_5: pass -> [missing] (J1)
  • errors::verify_mir_build_lower_range_bound_must_be_less_than_upper_7: pass -> [missing] (J1)
  • errors::verify_mir_build_nan_pattern_21: pass -> [missing] (J1)
  • errors::verify_mir_build_pointer_pattern_22: pass -> [missing] (J1)
  • errors::verify_mir_build_trailing_irrefutable_let_patterns_9: pass -> [missing] (J1)
  • errors::verify_mir_build_type_not_structural_18: [missing] -> pass (J1)
  • errors::verify_mir_build_union_pattern_16: pass -> [missing] (J1)
  • errors::verify_mir_build_unreachable_due_to_uninhabited_3: [missing] -> pass (J1)
  • errors::verify_mir_build_unsized_pattern_20: pass -> [missing] (J1)
  • errors::verify_mir_build_unsized_pattern_21: [missing] -> pass (J1)
  • errors::verify_mir_transform_unused_assign_passed_9: [missing] -> pass (J1)
  • errors::verify_mir_transform_unused_capture_maybe_capture_ref_8: [missing] -> pass (J1)
  • errors::verify_passes_custom_mir_incompatible_dialect_and_phase_142: pass -> [missing] (J1)
  • errors::verify_passes_custom_mir_phase_requires_dialect_137: [missing] -> pass (J1)
  • errors::verify_passes_ineffective_unstable_impl_127: pass -> [missing] (J1)
  • errors::verify_passes_repr_align_should_be_align_139: pass -> [missing] (J1)
  • errors::verify_passes_repr_align_should_be_align_static_136: [missing] -> pass (J1)
  • errors::verify_passes_repr_align_should_be_align_static_140: pass -> [missing] (J1)
  • errors::verify_passes_sanitize_attribute_not_allowed_125: [missing] -> pass (J1)
  • errors::verify_passes_sanitize_attribute_not_allowed_129: pass -> [missing] (J1)
  • errors::verify_passes_unexportable_adt_with_private_fields_134: [missing] -> pass (J1)
  • errors::verify_passes_unexportable_fn_abi_130: [missing] -> pass (J1)
  • errors::verify_passes_unexportable_fn_abi_134: pass -> [missing] (J1)
  • errors::verify_passes_unexportable_generic_fn_129: [missing] -> pass (J1)
  • errors::verify_passes_unexportable_priv_item_133: [missing] -> pass (J1)
  • errors::verify_passes_unexportable_type_repr_131: [missing] -> pass (J1)
  • errors::verify_passes_unexportable_type_repr_135: pass -> [missing] (J1)
  • errors::verify_passes_unnecessary_partial_stable_feature_126: pass -> [missing] (J1)
  • errors::verify_passes_unused_assign_passed_128: pass -> [missing] (J1)
  • errors::verify_passes_unused_capture_maybe_capture_ref_124: pass -> [missing] (J1)
  • errors::verify_passes_unused_var_maybe_capture_ref_123: pass -> [missing] (J1)

Stage 1

  • errors::verify_mir_build_bindings_with_variant_name_10: pass -> [missing] (J0)
  • errors::verify_mir_build_const_continue_bad_const_31: pass -> [missing] (J0)
  • errors::verify_mir_build_const_continue_missing_label_or_value_33: [missing] -> pass (J0)
  • errors::verify_mir_build_const_continue_unknown_jump_target_34: [missing] -> pass (J0)
  • errors::verify_mir_build_const_pattern_depends_on_generic_parameter_3: pass -> [missing] (J0)
  • errors::verify_mir_build_invalid_pattern_19: pass -> [missing] (J0)
  • errors::verify_mir_build_invalid_pattern_20: [missing] -> pass (J0)
  • errors::verify_mir_build_irrefutable_let_patterns_if_let_11: pass -> [missing] (J0)
  • errors::verify_mir_build_irrefutable_let_patterns_if_let_guard_12: pass -> [missing] (J0)
  • errors::verify_mir_build_irrefutable_let_patterns_while_let_14: pass -> [missing] (J0)
  • errors::verify_mir_build_irrefutable_let_patterns_while_let_15: [missing] -> pass (J0)
  • errors::verify_mir_build_leading_irrefutable_let_patterns_8: pass -> [missing] (J0)
  • errors::verify_mir_build_literal_in_range_out_of_bounds_7: [missing] -> pass (J0)
  • errors::verify_mir_build_loop_match_arm_with_guard_30: pass -> [missing] (J0)
  • errors::verify_mir_build_loop_match_bad_rhs_28: pass -> [missing] (J0)
  • errors::verify_mir_build_loop_match_bad_rhs_29: [missing] -> pass (J0)
  • errors::verify_mir_build_loop_match_bad_statements_27: pass -> [missing] (J0)
  • errors::verify_mir_build_loop_match_invalid_match_25: pass -> [missing] (J0)
  • errors::verify_mir_build_loop_match_invalid_update_25: [missing] -> pass (J0)
  • errors::verify_mir_build_loop_match_missing_assignment_29: pass -> [missing] (J0)
  • errors::verify_mir_build_loop_match_unsupported_type_26: pass -> [missing] (J0)
  • errors::verify_mir_build_loop_match_unsupported_type_27: [missing] -> pass (J0)
  • errors::verify_mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper_5: pass -> [missing] (J0)
  • errors::verify_mir_build_nan_pattern_21: pass -> [missing] (J0)
  • errors::verify_mir_build_nan_pattern_22: [missing] -> pass (J0)
  • errors::verify_mir_build_non_partial_eq_match_19: [missing] -> pass (J0)
  • errors::verify_mir_build_pointer_pattern_23: [missing] -> pass (J0)
  • errors::verify_mir_build_union_pattern_16: pass -> [missing] (J0)
  • errors::verify_mir_build_unsized_pattern_20: pass -> [missing] (J0)
  • errors::verify_mir_build_unsized_pattern_21: [missing] -> pass (J0)
  • errors::verify_mir_transform_unused_capture_maybe_capture_ref_8: [missing] -> pass (J0)
  • errors::verify_passes_custom_mir_incompatible_dialect_and_phase_142: pass -> [missing] (J0)
  • errors::verify_passes_ineffective_unstable_impl_124: [missing] -> pass (J0)
  • errors::verify_passes_repr_align_should_be_align_static_140: pass -> [missing] (J0)
  • errors::verify_passes_rustc_const_stable_indirect_pairing_126: [missing] -> pass (J0)
  • errors::verify_passes_sanitize_attribute_not_allowed_129: pass -> [missing] (J0)
  • errors::verify_passes_unexportable_fn_abi_130: [missing] -> pass (J0)
  • errors::verify_passes_unexportable_fn_abi_134: pass -> [missing] (J0)
  • errors::verify_passes_unexportable_generic_fn_129: [missing] -> pass (J0)
  • errors::verify_passes_unexportable_item_128: [missing] -> pass (J0)
  • errors::verify_passes_unexportable_priv_item_137: pass -> [missing] (J0)
  • errors::verify_passes_unnecessary_stable_feature_125: pass -> [missing] (J0)
  • errors::verify_passes_unreachable_due_to_uninhabited_122: pass -> [missing] (J0)
  • errors::verify_passes_unused_var_maybe_capture_ref_123: pass -> [missing] (J0)

(and 108 additional test diffs)

Additionally, 168 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard ff6dc928c5e33ce8e65c6911a790b9efcb5ef53a --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-sparcv9-solaris: 5176.6s -> 5996.1s (15.8%)
  2. dist-aarch64-apple: 7566.6s -> 6441.8s (-14.9%)
  3. aarch64-apple: 8625.1s -> 7424.7s (-13.9%)
  4. i686-gnu-2: 5400.7s -> 6017.6s (11.4%)
  5. pr-check-1: 1394.6s -> 1545.5s (10.8%)
  6. i686-gnu-nopt-1: 7276.3s -> 8051.8s (10.7%)
  7. dist-apple-various: 3565.6s -> 3931.2s (10.3%)
  8. aarch64-gnu: 6232.0s -> 6813.1s (9.3%)
  9. aarch64-msvc-2: 5192.0s -> 4748.3s (-8.5%)
  10. dist-various-2: 2244.4s -> 2067.4s (-7.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@cjgillot cjgillot deleted the mir-liveness branch October 12, 2025 16:25
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ff6dc92): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.6% [0.1%, 2.0%] 75
Regressions ❌
(secondary)
0.7% [0.0%, 3.7%] 76
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 1
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.4%] 6
All ❌✅ (primary) 0.6% [-0.3%, 2.0%] 76

Max RSS (memory usage)

Results (primary 1.3%, secondary 0.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.9% [0.9%, 7.8%] 16
Regressions ❌
(secondary)
1.7% [0.9%, 2.5%] 20
Improvements ✅
(primary)
-3.5% [-6.2%, -0.9%] 2
Improvements ✅
(secondary)
-5.6% [-7.0%, -1.8%] 4
All ❌✅ (primary) 1.3% [-6.2%, 7.8%] 18

Cycles

Results (primary -2.6%, secondary 3.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.5% [1.5%, 5.8%] 13
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.6% [-2.6%, -2.6%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 471.9s -> 471.991s (0.02%)
Artifact size: 388.11 MiB -> 388.12 MiB (0.00%)

@Kobzol
Copy link
Member

Kobzol commented Oct 13, 2025

The regressions on the check builds are real, but they mostly didn't carry over to debug and opt builds. This is a big compiler change that took years to land, so I think that we just eat the cost.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Oct 13, 2025
bors added a commit that referenced this pull request Oct 17, 2025
Pre-compute MIR CFG caches for borrowck and other analyses

I was puzzled that #142390 introduces additional computations of CFG traversals: borrowck computes them, right?

It turns out that borrowck clones the MIR body, so doesn't share its cache with other analyses.

This PR:
- forces the computation of all caches in `mir_promoted` query;
- modifies region renumbering to avoid dropping that cache.
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Oct 22, 2025
Pre-compute MIR CFG caches for borrowck and other analyses

I was puzzled that rust-lang/rust#142390 introduces additional computations of CFG traversals: borrowck computes them, right?

It turns out that borrowck clones the MIR body, so doesn't share its cache with other analyses.

This PR:
- forces the computation of all caches in `mir_promoted` query;
- modifies region renumbering to avoid dropping that cache.
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Nov 3, 2025
Pre-compute MIR CFG caches for borrowck and other analyses

I was puzzled that rust-lang/rust#142390 introduces additional computations of CFG traversals: borrowck computes them, right?

It turns out that borrowck clones the MIR body, so doesn't share its cache with other analyses.

This PR:
- forces the computation of all caches in `mir_promoted` query;
- modifies region renumbering to avoid dropping that cache.
@apiraino
Copy link
Contributor

Nominating this PR for T-compiler discussion to boost signal the Zulip topic about the beta regressions that were reported
#t-compiler > collateral of #142390 on `unused` lints @ 💬

@rustbot label I-compiler-nominated

@rustbot rustbot added the I-compiler-nominated Nominated for discussion during a compiler team meeting. label Nov 19, 2025
@apiraino apiraino removed the I-compiler-nominated Nominated for discussion during a compiler team meeting. label Nov 27, 2025
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Nov 30, 2025
Perform unused assignment and unused variables lints on MIR.

Rebase of rust-lang#101500

Fixes rust-lang#51003.

The first commit moves detection of uninhabited types from the current liveness pass to MIR building.

In order to keep the same level of diagnostics, I had to instrument MIR a little more:
- keep for which original local a guard local is created;
- store in the `VarBindingForm` the list of introducer places and whether this was a shorthand pattern.

I am not very proud of the handling of self-assignments. The proposed scheme is in two parts: first detect probable self-assignments, by pattern matching on MIR, and second treat them specially during dataflow analysis. I welcome ideas.

Please review carefully the changes in tests. There are many small changes to behaviour, and I'm not sure all of them are desirable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tidy Area: The tidy tool merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rewrite liveness analysis to be based on MIR