Skip to content

fix: \extract_function\ misses \&mut\ for \container[i].mut_method()\#22523

Merged
A4-Tacks merged 1 commit into
rust-lang:masterfrom
Albab-Hasan:extract-function-index-mut-method
Jun 6, 2026
Merged

fix: \extract_function\ misses \&mut\ for \container[i].mut_method()\#22523
A4-Tacks merged 1 commit into
rust-lang:masterfrom
Albab-Hasan:extract-function-index-mut-method

Conversation

@Albab-Hasan

Copy link
Copy Markdown
Contributor

`expr_require_exclusive_access` had no `IndexExpr` case so `container[i].mut_method()` fell through to `Some(false)`. `WRITE` is only set on direct assignments so method calls through an index were not detected as requiring exclusive access and the container was extracted as `&container` instead of `&mut container`.

fixes #20162

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 3, 2026
@A4-Tacks A4-Tacks enabled auto-merge June 5, 2026 08:54
@A4-Tacks

A4-Tacks commented Jun 6, 2026

Copy link
Copy Markdown
Member

Maybe you need to rebase

…od()\`

fixes rust-lang#20162

\`expr_require_exclusive_access\` had no \`IndexExpr\` case, so
\`container[i].mut_method()\` fell through to \`Some(false)\`. \`WRITE\` is only
set on direct assignments, so method calls through an index were not detected
as requiring exclusive access, and the container was extracted as \`&container\`
instead of \`&mut container\`.
auto-merge was automatically disabled June 6, 2026 14:57

Head branch was pushed to by a user without write access

@Albab-Hasan Albab-Hasan force-pushed the extract-function-index-mut-method branch from 55f59db to 256fe3e Compare June 6, 2026 14:57
@rustbot

rustbot commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@A4-Tacks A4-Tacks enabled auto-merge June 6, 2026 14:59
@A4-Tacks A4-Tacks added this pull request to the merge queue Jun 6, 2026
Merged via the queue into rust-lang:master with commit a9a66c4 Jun 6, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract into function produces incorrect results when IndexMut is involved

3 participants