Skip to content

fix: no deref index-expr for extract_function#22025

Merged
lnicola merged 1 commit intorust-lang:masterfrom
A4-Tacks:extract-fun-transparent-index
Apr 13, 2026
Merged

fix: no deref index-expr for extract_function#22025
lnicola merged 1 commit intorust-lang:masterfrom
A4-Tacks:extract-fun-transparent-index

Conversation

@A4-Tacks
Copy link
Copy Markdown
Member

@A4-Tacks A4-Tacks commented Apr 12, 2026

Fixes #22023

Example

fn foo() {
    let mut arr = [1i32];
    $0arr[0] = 3;$0
    let _ = arr;
}

Before this PR

fn foo() {
    let mut arr = [1i32];
    fun_name(&mut arr);
    let _ = arr;
}

fn $0fun_name(arr: &mut [i32; 1]) {
    *arr[0] = 3;
}

After this PR

fn foo() {
    let mut arr = [1i32];
    fun_name(&mut arr);
    let _ = arr;
}

fn $0fun_name(arr: &mut [i32; 1]) {
    arr[0] = 3;
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 12, 2026
Example
---
```rust
fn foo() {
    let mut arr = [1i32];
    $0arr[0] = 3;$0
    let _ = arr;
}
```

**Before this PR**

```rust
fn foo() {
    let mut arr = [1i32];
    fun_name(&mut arr);
    let _ = arr;
}

fn $0fun_name(arr: &mut [i32; 1]) {
    *arr[0] = 3;
}
```

**After this PR**

```rust
fn foo() {
    let mut arr = [1i32];
    fun_name(&mut arr);
    let _ = arr;
}

fn $0fun_name(arr: &mut [i32; 1]) {
    arr[0] = 3;
}
```
@A4-Tacks A4-Tacks force-pushed the extract-fun-transparent-index branch from e7081ba to 043421f Compare April 12, 2026 20:16
@lnicola lnicola added this pull request to the merge queue Apr 13, 2026
Merged via the queue into rust-lang:master with commit 0b3ff84 Apr 13, 2026
17 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 13, 2026
@A4-Tacks A4-Tacks deleted the extract-fun-transparent-index branch April 13, 2026 12:59
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: spurious * on index expressions causes E0614 when vec is promoted to &mut

3 participants