{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiamfqcrncidshbzaffp2idkzcnzfjtw775w27jjr26fui3g2bwquy",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mmtx7mlf2hn2"
},
"path": "/t/pre-rfc-unsafe-traits-conditionally-depending-on-safe-trait-behaviour/24360#post_2",
"publishedAt": "2026-05-27T16:27:11.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "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.\n\n* * *\n\nFor a bit of further context, the `Storage` proposal for generalizing allocators further has _two_ concepts of cloning. Using my current local revision's naming:\n\n * `DupStore`, which indicates that the clone duplicates its backing storage and is independent from the source; and\n * `UseStore`, which indicates that the clone shares its backing storage with the source.\n\n\n\nMy draft also includes methods on `Store` to clone bound on these traits e.g.\n\n\n final fn clone_dup(&self) -> Self\n where\n Self: DupStore,\n {\n self.clone()\n }\n\n\nI 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.",
"title": "Pre-RFC: Unsafe traits conditionally depending on safe trait behaviour"
}