Skip to content

Diagnostics say that the let in let chains has type bool #147665

@theemathas

Description

@theemathas

Code

fn main() {
    if let x = 1 && 2 {}
}

Current output

error[E0308]: mismatched types
 --> src/main.rs:2:21
  |
2 |     if let x = 1 && 2 {}
  |        ---------    ^ expected `bool`, found integer
  |        |
  |        expected because this is `bool`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` (bin "playground") due to 1 previous error

Desired output

Rationale and extra context

The compiler is saying that let x = 1 has type bool, which doesn't make much sense.

Other cases

Rust Version

Reproducible on the playground with version: 1.92.0-nightly (2025-10-13 4b94758d2ba7d0ef71cc)

Anything else?

Discovered by ashtree129 on the community discord.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions