Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest let or == on typo'd let-chain #118191

Merged
merged 1 commit into from
Nov 29, 2023
Merged

Commits on Nov 28, 2023

  1. Suggest let or == on typo'd let-chain

    When encountering a bare assignment in a let-chain, suggest turning the
    assignment into a `let` expression or an equality check.
    
    ```
    error: expected expression, found `let` statement
      --> $DIR/bad-if-let-suggestion.rs:5:8
       |
    LL |     if let x = 1 && i = 2 {}
       |        ^^^^^^^^^
       |
       = note: only supported directly in conditions of `if` and `while` expressions
    help: you might have meant to continue the let-chain
       |
    LL |     if let x = 1 && let i = 2 {}
       |                     +++
    help: you might have meant to compare for equality
       |
    LL |     if let x = 1 && i == 2 {}
       |                        +
    ```
    estebank committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    55e4e3e View commit details
    Browse the repository at this point in the history