const_panic/fmt_impls/
other_impls.rs

1use crate::{FmtArg, PanicVal};
2
3use core::{
4    marker::{PhantomData, PhantomPinned},
5    ptr::NonNull,
6};
7
8use core as std;
9
10macro_rules! ptr_impls {
11    ($ty:ty) => {
12        primitive_static_panicfmt! {
13            fn[T: ?Sized](&self: $ty, _f) {
14                PanicVal::write_str("<pointer>")
15            }
16        }
17    };
18}
19
20ptr_impls! {*const T}
21
22ptr_impls! {*mut T}
23
24ptr_impls! {NonNull<T>}
25
26impl_for_option! {
27    (for[T], 'static, NonNull<T>, NonNull<T>)
28}
29
30primitive_static_panicfmt! {
31    fn[T: ?Sized](&self: PhantomData<T>, _f) {
32        PanicVal::write_str("PhantomData")
33    }
34}
35
36primitive_static_panicfmt! {
37    fn[](&self: PhantomPinned, _f) {
38        PanicVal::write_str("PhantomPinned")
39    }
40}
41
42primitive_static_panicfmt! {
43    fn[](&self: (), _f) {
44        PanicVal::write_str("()")
45    }
46}
47
48impl_for_option! {
49    (for[], 'static, core::cmp::Ordering, core::cmp::Ordering)
50}
51primitive_static_panicfmt! {
52    fn[](&self: std::cmp::Ordering, _f) {
53        let v = match self.0 {
54            std::cmp::Ordering::Less => "Less",
55            std::cmp::Ordering::Equal => "Equal",
56            std::cmp::Ordering::Greater => "Greater",
57        };
58        PanicVal::write_str(v)
59    }
60}
61
62primitive_static_panicfmt! {
63    fn[](&self: std::sync::atomic::Ordering, _f) {
64        use std::sync::atomic::Ordering;
65        let v = match self.0 {
66            Ordering::Relaxed => "Relaxed",
67            Ordering::Release => "Release",
68            Ordering::Acquire => "Acquire",
69            Ordering::AcqRel => "AcqRel",
70            Ordering::SeqCst => "SeqCst",
71            _ => "<std::sync::atomic::Ordering>",
72        };
73        PanicVal::write_str(v)
74    }
75}
76
77#[allow(unreachable_code)]
78const _: () = {
79    primitive_static_panicfmt! {
80        fn[](&self: std::convert::Infallible, _f) {
81            match *self.0 {}
82        }
83    }
84};