Closed
Description
Given:
use std::marker::PhantomData;
const DATA: PhantomData<String> = PhantomData;
fn main() {
match PhantomData {
DATA => {}
};
}
results in:
error: to use a constant of type `std::marker::PhantomData` in a pattern,
`std::marker::PhantomData` must be annotated with `#[derive(PartialEq, Eq)]`
--> src/main.rs:7:9
|
7 | DATA => {}
| ^^^^
Is this intentional due to some soundness issue with having it otherwise? (I cannot think of any...)
We could fix this by attaching #[structural_match]
to PhantomData<T>
manually.
While having PhantomData<T>
be structurally matchable is quite boring and useless on its lonesome it prevents other types that contain it from being structurally matchable. (not likely to occur very often, but when it occur it seems like it would be annoying...)
cc @rust-lang/lang