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

Non-Exhaustive Patterns: Matching Error (E0004) #2311

Open
MahadMuhammad opened this issue Jun 21, 2023 · 1 comment
Open

Non-Exhaustive Patterns: Matching Error (E0004) #2311

MahadMuhammad opened this issue Jun 21, 2023 · 1 comment
Assignees
Labels

Comments

@MahadMuhammad
Copy link
Contributor

MahadMuhammad commented Jun 21, 2023

I tried this code to test error code E0004(Matching Error) on godbolt:

#![allow(unused)]
fn main() {
enum Terminator {
    HastaLaVistaBaby,
    TalkToMyHand,
}

let x = Terminator::HastaLaVistaBaby;

match x { // error: non-exhaustive patterns: `HastaLaVistaBaby` not covered
    Terminator::TalkToMyHand => {}
}
}

I expected to see this happen:

error[E0004]: non-exhaustive patterns: `HastaLaVistaBaby` not covered
  --> <source>:10:7
   |
3  | / enum Terminator {
4  | |     HastaLaVistaBaby,
   | |     ---------------- not covered
5  | |     TalkToMyHand,
6  | | }
   | |_- `Terminator` defined here
...
10 |   match x { // error: non-exhaustive patterns: `HastaLaVistaBaby` not covered
   |         ^ pattern `HastaLaVistaBaby` not covered
   |
   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
   = note: the matched value is of type `Terminator`

Instead, this happened:

Compiler returned: 0

Meta

  • What version of Rust GCC were you using, git sha 6c63150
    • gccrs (Compiler-Explorer-Build-gcc-7671253eda836193313586013e92dde3d14f5ebe-binutils-2.40) 13.0.1 20230417 (experimental)
@robertgoss
Copy link
Contributor

Would it be ok for me to pick this up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants