]> git.proxmox.com Git - rustc.git/blame - src/test/ui/rfc1445/allow-hide-behind-direct-unsafe-ptr-embedded.rs
New upstream version 1.39.0+dfsg1
[rustc.git] / src / test / ui / rfc1445 / allow-hide-behind-direct-unsafe-ptr-embedded.rs
CommitLineData
416331ca
XL
1// Test explores how `#[structral_match]` behaves in tandem with
2// `*const` and `*mut` pointers.
3
4// run-pass
5
6struct NoDerive(i32);
7
8// This impl makes NoDerive irreflexive
9// (which doesn't matter here because `<*const T>::eq` won't recur on `T`).
10impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
11
12impl Eq for NoDerive { }
13
14#[derive(PartialEq, Eq)]
15struct WrapEmbedded(*const NoDerive);
16
17const WRAP_UNSAFE_EMBEDDED: WrapEmbedded = WrapEmbedded(std::ptr::null());
18
19fn 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}