Pre-RFC: Unsafe traits conditionally depending on safe trait behaviour
Rust Internals [Unofficial]
May 27, 2026
Conceptually, at least, it does seem like it'd be nice to have something like this.
For example, TrustedLen wants to also put a requirement that ExactSizeIterator::len can't be garbage, but there's nothing on that trait impl (nor the len method) itself that acknowledges that.
Spitballing, this seems awkward:
nia-e:
#[unsafe(has_preconditions(Allocator))] trait Clone {}
because Clone is in core so if something that's not core -- such as external crates, if this wanted to become a "real" feature -- then they can't put something on Clone.
Discussion in the ATmosphere