Closed
Description
Given the following code:
enum Foo {
Variant1,
Variant2,
}
fn main() {
match Foo::Variant2 {
Foo::Variant1 => {}
}
}
The current output is:
Checking foo v0.1.0 (/Users/eric/Temp/foo)
error[E0004]: non-exhaustive patterns: `Variant2` not covered
--> src/main.rs:7:11
|
7 | match Foo::Variant2 {
| ^^^^^^^^^^^^^ pattern `Variant2` not covered
|
note: `Foo` defined here
--> src/main.rs:3:5
|
1 | enum Foo {
| ---
2 | Variant1,
3 | Variant2,
| ^^^^^^^^ not covered
= note: the matched value is of type `Foo`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
8 ~ Foo::Variant1 => {}
9 + Variant2 => todo!()
|
For more information about this error, try `rustc --explain E0004`.
error: could not compile `foo` due to previous error
The problem with the suggestion is that it suggests Variant2
without the Foo::
prefix. Ideally the suggestion should be:
9 + Foo::Variant2 => todo!()
The current suggestion does not compile.
rustc 1.65.0-nightly (9c20b2a8c 2022-08-17)