]> git.proxmox.com Git - rustc.git/blame - src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / src / test / ui / rfc-1445-restrict-constants-in-patterns / allow-hide-behind-indirect-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
1b1a35ee
XL
6#![warn(pointer_structural_match)]
7
064997fb 8struct NoDerive(#[allow(unused_tuple_struct_fields)] i32);
416331ca
XL
9
10// This impl makes NoDerive irreflexive
11// (which doesn't matter here because `<*const T>::eq` won't recur on `T`).
12impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
13
14impl Eq for NoDerive { }
15
16#[derive(PartialEq, Eq)]
17struct WrapEmbedded(*const NoDerive);
18
19const WRAP_UNSAFE_EMBEDDED: & &WrapEmbedded = & &WrapEmbedded(std::ptr::null());
20
21fn main() {
22 match WRAP_UNSAFE_EMBEDDED {
23 WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); }
24 _ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); }
25 }
26}