/// This is never implemented (mainly, by `WrongDyn = ()`).
/// This significantly improves the diagnostics when feeding an incorrect `dyn Fn…` to
/// an `Arc`.
pub trait NeverImplemented {}

// All these impls take priority over the horrendous "missing `NonOpaque` for `dyn …`" we were
// otherwise getting.
#[rustfmt::skip]
macro_rules! improve_lack_of_PointeeFitForCArc_impl_diagnostics {(
    dyn Send? + Sync? + FnMut?($($Arg:ident),*) -> $R:ident,
) => (
    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCArc<WrongDyn>
    for
        dyn 'static + Fn($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CArced = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCArc<WrongDyn>
    for
        dyn 'static + Send + Fn($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CArced = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCArc<WrongDyn>
    for
        dyn 'static + Sync + Fn($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CArced = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCArc<WrongDyn>
    for
        dyn 'static + Send + Sync + FnMut($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CArced = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCArc<WrongDyn>
    for
        dyn 'static + Send + FnMut($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CArced = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCArc<WrongDyn>
    for
        dyn 'static + FnMut($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CArced = ();
    }
)}
pub(super) use improve_lack_of_PointeeFitForCArc_impl_diagnostics;

#[rustfmt::skip]
macro_rules! improve_lack_of_PointeeFitForCBox_impl_diagnostics {(
    dyn Send? + Sync? + Fn?($($Arg:ident),*) -> $R:ident,
) => (
    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCBox<WrongDyn>
    for
        dyn 'static + FnMut($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CBoxed = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCBox<WrongDyn>
    for
        dyn 'static + Sync + FnMut($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CBoxed = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCBox<WrongDyn>
    for
        dyn 'static + Send + Sync + FnMut($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CBoxed = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCBox<WrongDyn>
    for
        dyn 'static + Send + Sync + Fn($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CBoxed = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCBox<WrongDyn>
    for
        dyn 'static + Send + Fn($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CBoxed = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCBox<WrongDyn>
    for
        dyn 'static + Sync + Fn($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CBoxed = ();
    }

    impl<
        WrongDyn,
        $R : ReprC $(, $Arg : ReprC)*
    >
        PointeeFitForCBox<WrongDyn>
    for
        dyn 'static + Fn($($Arg),*) -> $R
    where
        WrongDyn : repr_c_ptr_dyn_diagnostics::NeverImplemented,
    {
        type CBoxed = ();
    }
)}
pub(super) use improve_lack_of_PointeeFitForCBox_impl_diagnostics;
