Skip to content

Conversation

@A4-Tacks
Copy link
Member

@A4-Tacks A4-Tacks commented Dec 10, 2025

Partial of #20967

  • And fix fallback parentheses

Example

fn foo() {
    let foo = Some("foo");
    return foo.and$0(Some("bar"));
}

Before this PR

fn foo() {
    let foo = Some("foo");
    return foo.and_then(|| Some("bar"));
}

After this PR

fn foo() {
    let foo = Some("foo");
    return foo.and_then(|it| Some("bar"));
}

struct Func { f: fn() -> i32 }
fn foo() {
    let foo = true;
    let func = Func { f: || 2 };
    let x = foo.then$0(func.f);
}

Before this PR

request handler panicked: Failed to make ast node `syntax::ast::generated::nodes::CallExpr` from text const C: () = func.f();

After this PR

struct Func { f: fn() -> i32 }
fn foo() {
    let foo = true;
    let func = Func { f: || 2 };
    let x = foo.then_some((func.f)());
}

- And fix fallback parentheses

Example
---
```rust
fn foo() {
    let foo = Some("foo");
    return foo.and$0(Some("bar"));
}
```

**Before this PR**

```rust
fn foo() {
    let foo = Some("foo");
    return foo.and_then(|| Some("bar"));
}
```

**After this PR**

```rust
fn foo() {
    let foo = Some("foo");
    return foo.and_then(|it| Some("bar"));
}
```

---

```rust
struct Func { f: fn() -> i32 }
fn foo() {
    let foo = true;
    let func = Func { f: || 2 };
    let x = foo.then$0(func.f);
}
```

**Before this PR**

```text
request handler panicked: Failed to make ast node `syntax::ast::generated::nodes::CallExpr` from text const C: () = func.f();
```

**After this PR**

```rust
struct Func { f: fn() -> i32 }
fn foo() {
    let foo = true;
    let func = Func { f: || 2 };
    let x = foo.then_some((func.f)());
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 10, 2025
@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Dec 11, 2025
Merged via the queue into rust-lang:master with commit a3f0193 Dec 11, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 11, 2025
@A4-Tacks A4-Tacks deleted the eager-param-and-paren branch December 11, 2025 12:21
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