Skip to content

fix: do not convert mut ref arg for generate_function#22720

Open
A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:gen-func-mut-arg
Open

fix: do not convert mut ref arg for generate_function#22720
A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:gen-func-mut-arg

Conversation

@A4-Tacks

@A4-Tacks A4-Tacks commented Jul 4, 2026

Copy link
Copy Markdown
Member

Considering like Option::get_or_insert Vec::push, this is not suitable for conversion

Example

struct S;
fn foo() {
    $0bar(&mut Some(S))
}

Before this PR

fn bar(s: Option<&S>) {
    ${0:todo!()}
}

After this PR

fn bar(s: &mut Option<S>) {
    ${0:todo!()}
}

Considering like `Option::get_or_insert` `Vec::push`, this is not suitable for conversion

Example
---
```rust
struct S;
fn foo() {
    $0bar(&mut Some(S))
}
```

**Before this PR**

```rust
fn bar(s: Option<&S>) {
    ${0:todo!()}
}
```

**After this PR**

```rust
fn bar(s: &mut Option<S>) {
    ${0:todo!()}
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants