Skip to content

Conversation

@Unique-Usman
Copy link
Contributor

No description provided.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 22, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 22, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Unique-Usman
Copy link
Contributor Author

My approach seems not to be perfect and I have been stucked on this for a while. This is the issue this is supposed to fix - >#117977

@Unique-Usman Unique-Usman marked this pull request as draft January 22, 2026 15:06
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 22, 2026
@Unique-Usman
Copy link
Contributor Author

@estebank

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
@Unique-Usman Unique-Usman marked this pull request as ready for review January 27, 2026 21:35
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 27, 2026
@Unique-Usman
Copy link
Contributor Author

r? @estebank

@rustbot rustbot assigned estebank and unassigned chenyukang Jan 27, 2026
@Unique-Usman
Copy link
Contributor Author

This is an improvement for

fn main() {
    let x = Some(42);
    if let Some(_) = x
        && Some(x) = x
    {}
}

initially it gives

error: expected expression, found `let` statement
 --> foo.rs:3:8
  |
3 |     if let Some(_) = x
  |        ^^^^^^^^^^^^^^^
  |
  = note: only supported directly in conditions of `if` and `while` expressions
help: you might have meant to continue the let-chain
  |
4 |         && let Some(x) = x
  |            +++
help: you might have meant to compare for equality
  |
4 |         && Some(x) == x
  |                     +

error[E0308]: mismatched types
 --> foo.rs:4:12
  |
4 |         && Some(x) = x
  |            ^^^^^^^ expected `bool`, found `Option<Option<{integer}>>`
  |
  = note: expected type `bool`
             found enum `Option<Option<{integer}>>`
help: use `Option::is_some` to test if the `Option` has a value
  |
4 |         && Some(x).is_some() = x
  |                   ++++++++++

error[E0308]: mismatched types
 --> foo.rs:3:8
  |
3 |       if let Some(_) = x
  |  ________^
4 | |         && Some(x) = x
  | |______________________^ expected `bool`, found `()`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.

but now it gives

error: expected expression, found `let` statement
 --> foo.rs:3:8
  |
3 |     if let Some(_) = x
  |        ^^^^^^^^^^^^^^^
  |
  = note: -Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/expr.rs:4263:51
  = note: only supported directly in conditions of `if` and `while` expressions
help: you might have meant to continue the let-chain
  |
4 |         && let Some(x) = x
  |            +++
help: you might have meant to compare for equality
  |
4 |         && Some(x) == x
  |                     +

error: aborting due to 1 previous error

@Unique-Usman
Copy link
Contributor Author

Interestingly,

fn main() {
    let x = Some(42);
    if let Some(_) = x
        && Some(x) = x
    {}
}

still give the same result.

error: expected expression, found `let` statement
 --> foo.rs:4:12
  |
4 |         && let Some(x) = x
  |            ^^^
  |
  = note: only supported directly in conditions of `if` and `while` expressions

error[E0308]: mismatched types
 --> foo.rs:3:18
  |
3 |     if Some(_) = x
  |                  ^ expected `bool`, found `Option<{integer}>`
  |
  = note: expected type `bool`
             found enum `Option<{integer}>`

error[E0308]: mismatched types
 --> foo.rs:3:8
  |
3 |       if Some(_) = x
  |  ________^^^^^^^___-
  | |        |
  | |        expected `bool`, found `Option<_>`
4 | |         && let Some(x) = x
  | |__________________________- this expression has type `bool`
  |
  = note: expected type `bool`
             found enum `Option<_>`

error[E0308]: mismatched types
 --> foo.rs:3:8
  |
3 |       if Some(_) = x
  |  ________^
4 | |         && let Some(x) = x
  | |__________________________^ expected `bool`, found `()`
  |
help: consider adding `let`
  |
3 |     if let Some(_) = x
  |        +++

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0308`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants