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

Increase accuracy of if condition misparse suggestion #133051

Merged
merged 4 commits into from
Nov 17, 2024

Commits on Nov 16, 2024

  1. Increase accuracy of if condition misparse suggestion

    Look at the expression that was parsed when trying to recover from a bad `if` condition to determine what was likely intended by the user beyond "maybe this was meant to be an `else` body".
    
    ```
    error: expected `{`, found `map`
      --> $DIR/missing-dot-on-if-condition-expression-fixable.rs:4:30
       |
    LL |     for _ in [1, 2, 3].iter()map(|x| x) {}
       |                              ^^^ expected `{`
       |
    help: you might have meant to write a method call
       |
    LL |     for _ in [1, 2, 3].iter().map(|x| x) {}
       |                              +
    ```
    estebank committed Nov 16, 2024
    Configuration menu
    Copy the full SHA
    04fe839 View commit details
    Browse the repository at this point in the history
  2. Better account for else if macro conditions mising an if

    If a macro statement has been parsed after `else`, suggest a missing `if`:
    
    ```
    error: expected `{`, found `falsy`
      --> $DIR/else-no-if.rs:47:12
       |
    LL |     } else falsy! {} {
       |       ---- ^^^^^
       |       |
       |       expected an `if` or a block after this `else`
       |
    help: add an `if` if this is the condition of a chained `else if` statement
       |
    LL |     } else if falsy! {} {
       |            ++
    ```
    estebank committed Nov 16, 2024
    Configuration menu
    Copy the full SHA
    629a69f View commit details
    Browse the repository at this point in the history
  3. Reword suggestion message

    estebank committed Nov 16, 2024
    Configuration menu
    Copy the full SHA
    c09c73b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6913194 View commit details
    Browse the repository at this point in the history