Closed
Description
use std::marker::PhantomData;
enum Void {}
enum Foo<T=()> {
Bar,
Baz,
Phantom(PhantomData<T>, Void)
}
pub fn test(f: Foo) {
match f {
Foo::Bar => println!("Bar"),
Foo::Baz => println!("Baz"),
}
}
I expect this to work, since the Phantom case is not constructible, since it contains a Void type.
The exhaustiveness checker instead errors because it thinks that the Phantom case should be covered as well:
error[E0004]: non-exhaustive patterns: `Phantom(_, _)` not covered
--> src/lib.rs:12:11
|
5 | / enum Foo<T=()> {
6 | | Bar,
7 | | Baz,
8 | | Phantom(PhantomData<T>, Void)
| | ------- not covered
9 | | }
| |_- `Foo` defined here
...
12 | match f {
| ^ pattern `Phantom(_, _)` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error: aborting due to previous error
Meta
Happens on stable and nightly as of 2020-03-04