//! A workaround for the `!` type in stable Rust.1//!2//! This approach is taken from the [`never_say_never`] crate,3//! reimplemented here to avoid adding a new dependency.4//!5//! This module exists due to a change in [never type fallback inference] in the Rust 2024 edition.6//! This caused failures in `bevy_ecs`'s traits which are implemented for functions7//! (like [`System`](crate::system::System)) when working with panicking closures.8//!9//! Note that using this hack is not recommended in general;10//! by doing so you are knowingly opting out of rustc's stability guarantees.11//! Code that compiles due to this hack may break in future versions of Rust.12//!13//! Please read [issue #18778](https://github.com/bevyengine/bevy/issues/18778) for an explanation of why14//! Bevy has chosen to use this workaround.15//!16//! [`never_say_never`]: https://crates.io/crates/never_say_never17//! [never type fallback inference]: https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html1819mod fn_ret {20/// A helper trait for naming the ! type.21#[doc(hidden)]22pub trait FnRet {23/// The return type of the function.24type Output;25}2627/// This blanket implementation allows us to name the never type,28/// by using the associated type of this trait for `fn() -> !`.29impl<R> FnRet for fn() -> R {30type Output = R;31}32}3334/// A hacky type alias for the `!` (never) type.35///36/// This knowingly opts out of rustc's stability guarantees.37/// Read the module documentation carefully before using this!38pub type Never = <fn() -> ! as fn_ret::FnRet>::Output;394041