Skip to content

fix: add param on result methods for replace_method_eager_lazy#22335

Merged
ChayimFriedman2 merged 4 commits into
rust-lang:masterfrom
A4-Tacks:lazy-method-param
May 15, 2026
Merged

fix: add param on result methods for replace_method_eager_lazy#22335
ChayimFriedman2 merged 4 commits into
rust-lang:masterfrom
A4-Tacks:lazy-method-param

Conversation

@A4-Tacks
Copy link
Copy Markdown
Member

@A4-Tacks A4-Tacks commented May 10, 2026

  • Add some Result methods to minicore
  • Migrate replace_method_eager_lazy to SyntaxEdutor

Example

fn foo() {
    let foo = Ok(1);
    return foo.unwrap_$0or(2);
}

Before this PR

fn foo() {
    let foo = Ok(1);
    return foo.unwrap_or_else(|| 2);
}

After this PR

fn foo() {
    let foo = Ok(1);
    return foo.unwrap_or_else(|${0:_}| 2);
}

A4-Tacks added 2 commits May 10, 2026 15:06
Example
---
```rust
fn foo() {
    let foo = Ok(1);
    return foo.unwrap_$0or(2);
}
```

**Before this PR**

```rust
fn foo() {
    let foo = Ok(1);
    return foo.unwrap_or_else(|| 2);
}
```

**After this PR**

```rust
fn foo() {
    let foo = Ok(1);
    return foo.unwrap_or_else(|e| 2);
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 10, 2026
@A4-Tacks A4-Tacks changed the title lazy method param fix: add param on result methods for replace_method_eager_lazy May 11, 2026
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to name the param _ given it's not used, and also place a snippet on it.

View changes since this review

@A4-Tacks
Copy link
Copy Markdown
Member Author

It seems good, I hope this won't break some habits

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue May 15, 2026
Merged via the queue into rust-lang:master with commit 961b5b0 May 15, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 15, 2026
@A4-Tacks A4-Tacks deleted the lazy-method-param branch May 15, 2026 04:17
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.

3 participants