try_specialize/unreliable/
mod.rs

1//! This module contains a set of functions, traits and macros that depend on
2//! undocumented standard library behavior and should therefore be used with
3//! caution.
4//!
5//! Library tests ensure that the `impls_trait` checks are performed at compile
6//! time and are fully optimized with no runtime cost at `opt-level >= 1`. Note
7//! that the release profile uses `opt-level = 3` by default.
8//!
9//! # Reliability
10//!
11//! While it is unlikely, there is still a possibility that functions in this
12//! module may return false negatives in future Rust versions.
13//!
14//! The correctness of the results returned by the functions depends on
15//! the following:
16//! - Documented behavior that if `T` implements `Eq`, two `Rc`s that point to
17//!   the same allocation are always equal:
18//!   <https://doc.rust-lang.org/1.82.0/std/rc/struct.Rc.html#method.eq>.
19//! - Undocumented behavior that the `Rc::partial_eq` implementation for `T: Eq`
20//!   will not use `PartialEq::eq` if both `Rc`s point to the same memory
21//!   location.
22//! - The assumption that the undocumented short-circuit behavior described
23//!   above will be retained for optimization purposes.
24//!
25//! There is no formal guarantee that the undocumented behavior described above
26//! will be retained. If the implementation changes in a future Rust version,
27//! the function may return a false negative, that is, it may return `false`,
28//! even though `T` implements the trait. However, the implementation guarantees
29//! that a false positive result is impossible, i.e., the function will never
30//! return true if `T` does not implement the trait in any future Rust version.
31//!
32//! Details:
33//! - <https://internals.rust-lang.org/t/rc-uses-visibly-behavior-changing-specialization-is-that-okay/16173/6>,
34//! - <https://users.rust-lang.org/t/hack-to-specialize-w-write-for-vec-u8/100366>,
35//! - <https://doc.rust-lang.org/1.82.0/std/rc/struct.Rc.html#method.eq>,
36//! - <https://github.com/rust-lang/rust/issues/42655>.
37
38mod impls_trait;
39mod try_specialize_weak;
40mod weak_specialization;
41
42pub use impls_trait::*;
43pub use try_specialize_weak::*;
44pub use weak_specialization::*;