-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-type-systemArea: Type systemArea: Type systemT-langRelevant to the language teamRelevant to the language team
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
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemT-langRelevant to the language teamRelevant to the language team