# Documenting more layout guarantees

**URL:** <https://internals.rust-lang.org/t/documenting-more-layout-guarantees/15032>\
**Category:** Unsafe Code Guidelines\
**Created:** [July 16, 2021, 6:34pm UTC](https://internals.rust-lang.org/t/documenting-more-layout-guarantees/15032 "2021-07-16T18:34:12Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [July 16, 2021, 10:45pm UTC](https://internals.rust-lang.org/t/documenting-more-layout-guarantees/15032/8 "2021-07-16T22:45:26Z")

</div>

It's interesting that the intent discussed there doesn't match [rustc's current behavior](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f1a474c9752403526412c764129cda86), which avoids niche optimization for `UnsafeCell` and `RefCell`, but still does it for `Cell`, `RwLock`, and `Mutex`.

Though I suppose for `RwLock`/`Mutex` it might be niching a different part of the structure, e.g. the `Box` for the system impl. So that could match the discussed plan + reënabling niching for `Cell`.

---

_[View the full topic](https://internals.rust-lang.org/t/documenting-more-layout-guarantees/15032)._
