rust-lang / rust-lang/rust

`{ expr1 } || expr2;` logical or / closure ambiguity

Open
#150,552 6 comments 0 reactions 1 assignee View on GitHub

@BartSimpson001 is already working on this.

Since Jan 1, 2026.

A-diagnostics T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
fn main() {
    { false } || { true };
}
Current output
error[E0308]: mismatched types
 --> src/main.rs:2:7
  |
2 |     { false } || { true };
  |       ^^^^^ expected `()`, found `bool`

For more information about this error, try `rustc --explain E0308`.
Desired output
help: parentheses are required to parse this as an expression
  |
2 |     ({ false } || { true });

help: use `if` instead
  |
2 |     if !{ false } { { true }; }
Rationale and extra context

Probably something left out by #60188

Other cases

Rust Version
rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.