Pre-RFC: Unsafe traits conditionally depending on safe trait behaviour
Imo, having e.g. #[marker] unsafe trait UseAllocator: Allocator + Clone to mark clones that correctly share the allocator is honestly reasonable. It's a difference between #[unsafe(satisfies_preconditions(Allocator))] on the Clone impl (which now can't be derived) or an unsafe impl for UseAllocator. The former doesn't seem much better than the latter to justify the new mechanism for marking impls as fulfilling safety guarantees.
For a bit of further context, the Storage proposal for generalizing allocators further has two concepts of cloning. Using my current local revision's naming:
DupStore, which indicates that the clone duplicates its backing storage and is independent from the source; andUseStore, which indicates that the clone shares its backing storage with the source.
My draft also includes methods on Store to clone bound on these traits e.g.
final fn clone_dup(&self) -> Self
where
Self: DupStore,
{
self.clone()
}
I need to think through what cloning with just Store + Clone gives you further. I want it to be enough for Box::clone, i.e. can be used as a fresh new storage.
Discussion in the ATmosphere