]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | // Test explores how `#[structral_match]` behaves in tandem with |
2 | // `*const` and `*mut` pointers. | |
3 | ||
4 | // run-pass | |
5 | ||
6 | struct NoDerive(i32); | |
7 | ||
8 | // This impl makes NoDerive irreflexive | |
9 | // (which doesn't matter here because `<*const T>::eq` won't recur on `T`). | |
10 | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } | |
11 | ||
12 | impl Eq for NoDerive { } | |
13 | ||
14 | #[derive(PartialEq, Eq)] | |
15 | struct WrapEmbedded(*const NoDerive); | |
16 | ||
17 | const WRAP_UNSAFE_EMBEDDED: WrapEmbedded = WrapEmbedded(std::ptr::null()); | |
18 | ||
19 | fn main() { | |
20 | match WRAP_UNSAFE_EMBEDDED { | |
21 | WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); } | |
22 | _ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); } | |
23 | } | |
24 | } |