Skip to content

Conversation

@A4-Tacks
Copy link
Member

@A4-Tacks A4-Tacks commented Nov 3, 2025

When completing some expressions, it is almost always expected to have a non unit value

Partial of #20390

  • ArrayExpr
  • ParenExpr
  • BreakExpr
  • ReturnExpr
  • PrefixExpr
  • FormatArgsArg
  • RecordExprField
  • BinExpr (rhs only)
  • IndexExpr (inside index only)

Example

fn main() {
    return $0;
}

Before this PR

fn main() {
    return if $1 {
        $0
    };
}

After this PR

fn main() {
    return if $1 {
        $2
    } else {
        $0
    };
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 3, 2025
When completing some expressions, it is almost always expected to have a non unit value

- ArrayExpr
- ParenExpr
- BreakExpr
- ReturnExpr
- PrefixExpr
- FormatArgsArg
- RecordExprField
- BinExpr (rhs only)
- IndexExpr (inside index only)

Example
---
```rust
fn main() {
    return $0;
}
```

**Before this PR**

```rust
fn main() {
    return if $1 {
        $0
    };
}
```

**After this PR**

```rust
fn main() {
    return if $1 {
        $2
    } else {
        $0
    };
}
```
@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Nov 4, 2025
Merged via the queue into rust-lang:master with commit 43df584 Nov 4, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 4, 2025
@A4-Tacks A4-Tacks deleted the more-in-value branch November 4, 2025 05:55
@lnicola lnicola changed the title Add more expression to 'in_value' fix: consider more expression types as 'in_value' Nov 4, 2025
@lnicola lnicola changed the title fix: consider more expression types as 'in_value' fix: consider more expression types as in_value Nov 4, 2025
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