--- /dev/null
+pub struct CustomEq;
+
+impl Eq for CustomEq {}
+impl PartialEq for CustomEq {
+ fn eq(&self, _: &Self) -> bool {
+ false
+ }
+}
+
+pub const NONE: Option<CustomEq> = None;
+pub const SOME: Option<CustomEq> = Some(CustomEq);
--- /dev/null
+// aux-build:consts.rs
+
+#![warn(indirect_structural_match)]
+
+extern crate consts;
+use consts::*;
+
+fn main() {
+ match None {
+ SOME => panic!(),
+ //~^ must be annotated with `#[derive(PartialEq, Eq)]`
+ //~| must be annotated with `#[derive(PartialEq, Eq)]`
+
+ _ => {}
+ }
+}
--- /dev/null
+error: to use a constant of type `consts::CustomEq` in a pattern, `consts::CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
+ --> $DIR/cross-crate-fail.rs:10:9
+ |
+LL | SOME => panic!(),
+ | ^^^^
+
+error: to use a constant of type `consts::CustomEq` in a pattern, `consts::CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
+ --> $DIR/cross-crate-fail.rs:10:9
+ |
+LL | SOME => panic!(),
+ | ^^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// run-pass
+// aux-build:consts.rs
+
+#![warn(indirect_structural_match)]
+
+extern crate consts;
+use consts::*;
+
+fn main() {
+ match Some(CustomEq) {
+ NONE => panic!(),
+ _ => {}
+ }
+}