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

Detect const in pattern with typo #132658

Merged
merged 1 commit into from
Nov 23, 2024
Merged

Commits on Nov 20, 2024

  1. Detect const in pattern with typo

    When writing a constant name incorrectly in a pattern, the pattern will be identified as a new binding. We look for consts in the current crate, consts that where imported in the current crate and for local `let` bindings in case someone got them confused with `const`s.
    
    ```
    error: unreachable pattern
      --> $DIR/const-with-typo-in-pattern-binding.rs:30:9
       |
    LL |         GOOOD => {}
       |         ----- matches any value
    LL |
    LL |         _ => {}
       |         ^ no value can reach this
       |
    help: you might have meant to pattern match against the value of similarly named constant `GOOD` instead of introducing a new catch-all binding
       |
    LL |         GOOD => {}
       |         ~~~~
    ```
    
    Fix rust-lang#132582.
    estebank committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    2487765 View commit details
    Browse the repository at this point in the history