# Pointers Are Complicated II, or: We need better language specs

**URL:** <https://internals.rust-lang.org/t/pointers-are-complicated-ii-or-we-need-better-language-specs/13562>\
**Category:** Uncategorized\
**Created:** [December 14, 2020, 4:34pm UTC](https://internals.rust-lang.org/t/pointers-are-complicated-ii-or-we-need-better-language-specs/13562 "2020-12-14T16:34:32Z")\
**Posts on this page:** 1\
**Showing post:** 87

<div class="post-metadata">

**Author:** ![notriddle](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/notriddle/32/14082_2.png) [@notriddle](https://internals.rust-lang.org/u/notriddle)\
**Post date:** [January 8, 2021, 9:20pm UTC](https://internals.rust-lang.org/t/pointers-are-complicated-ii-or-we-need-better-language-specs/13562/87 "2021-01-08T21:20:21Z")

</div>

> [@flatffinger](#):
>
> How often would it necessary to persist freely aliasable pointers _to things other than top-level objects_

Zero-copy parsers do it all the time, but they're usually treating the source as immutable, so that's probably not super-relevant.

As for treating "top level" objects specially, and allowing different aliasing rules for them, Rust already has that, too. It's called `UnsafeCell`, and its wrappers, which include `Cell`, `RefCell`, `Mutex`, and `RwLock`. You can't technically accomplish your example using them, but they generally do confer a lot of flexibility, and the rules governing them seem close to the ones you gave. Namely, two `Cell`s can alias, but partially aliasing them [could cause pointer invalidation issues](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a97e6210fb09666aaacdc463030b7a05), so it isn't necessarily safe.

---

_[View the full topic](https://internals.rust-lang.org/t/pointers-are-complicated-ii-or-we-need-better-language-specs/13562)._
