{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiasag6qzl3mcyrh3yddbfoyxcuesdmgasg5n5pnjlw6baatdovsau",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mhyxlv4plgu2"
},
"path": "/t/on-replacing-unsafecell/24113#post_3",
"publishedAt": "2026-03-26T17:29:43.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"Debug defined on the unsafecell"
],
"textContent": "ProgramCrafter:\n\n> structs are now also allowed to have _twilight_ fields which are internally mutable and potentially uninitialized\n\nI'm generally opposed to any feature which makes fields not uphold their usual invariants. If the field is `i32` and you can get an `&i32`, that should be a legal `&i32`, but that doesn't hold here.\n\nThe wrapper type is really useful because getting a `&UnsafeCell<i32>` is perfectly fine -- it can be passed around, it can have Debug defined on the unsafecell so that `derive(Debug)` works, etc.\n\nAttributes that add _extra_ guarantees is fine -- a `&i32` to a field with `#[align(128)]` is still usable, for example -- but removing type things is best done with a wrapper, not an attribute.",
"title": "On replacing UnsafeCell"
}