about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/attributes/inline.rs
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-12 20:37:52 +1000
committerGitHub <noreply@github.com>2025-08-12 20:37:52 +1000
commit55cb4b294ccfa3c77549bf6e7ac7a7772ee7ce84 (patch)
tree3a7ad51071a9c2c451ee0e25da77a30fc7b78c4a /compiler/rustc_attr_parsing/src/attributes/inline.rs
parent9fd770230561ce47456daf7275e066d363e92db4 (diff)
parentba350ff9110de2c75dab1e9530b63898bdc10154 (diff)
downloadrust-55cb4b294ccfa3c77549bf6e7ac7a7772ee7ce84.tar.gz
rust-55cb4b294ccfa3c77549bf6e7ac7a7772ee7ce84.zip
Rollup merge of #145214 - notJoon:fix/enable-self-assignment, r=petrochenkov
fix: re-enable self-assignment

## Description

Re-enables the self-assignment detection that was previously disabled due to unrelated regressions. The fix detects useless assignments like `x = x` and `foo.field = foo.field`.

## History

The original regressions (rust-lang/rust#81626, rust-lang/rust#81658) were specifically about false positives in write-only field detection, not self-assignment detection. Belows are brief history for the rule that I understand.

- Self-assignment detection was originally implemented in rust-lang/rust#87129 to address rust-lang/rust#75356
- The implementation was disabled alongside the revert of rust-lang/rust#81473's "write-only fields" detection
- rust-lang/rust#81473 was reverted via rust-lang/rust#86212 and rust-lang/rust#83171 due to false positives in write-only field detection (rust-lang/rust#81626, rust-lang/rust#81658)
- The self-assignment detection feature got removed, even though it wasn't the reason for the problems

This PR only re-enables the self-assignment checks, which are orthogonal to the problematic write-only field analysis.

## Changes
- Removed `#[allow(dead_code)]` from `compiler/rustc_passes/src/dead.rs` file
    - `handle_assign` and
    - `check_for_self_assign`
- Added `ExprKind::Assign` handling in `visit_expr` to call both methods
- Updated test expectations in `tests/ui/lint/dead-code/self-assign.rs`
Diffstat (limited to 'compiler/rustc_attr_parsing/src/attributes/inline.rs')
0 files changed, 0 insertions, 0 deletions