# Add rustc flag to disable mutable no-aliasing optimizations?

**URL:** <https://internals.rust-lang.org/t/add-rustc-flag-to-disable-mutable-no-aliasing-optimizations/14404>\
**Category:** compiler\
**Created:** [April 2, 2021, 4:21am UTC](https://internals.rust-lang.org/t/add-rustc-flag-to-disable-mutable-no-aliasing-optimizations/14404 "2021-04-02T04:21:20Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![jgarvin](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jgarvin/32/5329_2.png) [@jgarvin](https://internals.rust-lang.org/u/jgarvin)\
**Post date:** [April 3, 2021, 4:17pm UTC](https://internals.rust-lang.org/t/add-rustc-flag-to-disable-mutable-no-aliasing-optimizations/14404/20 "2021-04-03T16:17:24Z")

</div>

> [@comex](#):
>
> This is because it's a truly zero-overhead abstraction compared to just applying a lang item attribute to my own struct – in the sense that it does not generate any additional assembly or trace in the binary whatsoever. (Except for debug info, but whatever; Rust's debugger story has bigger problems than that.)

Even just at the assembly level, [in debug builds it's not zero cost.](https://internals.rust-lang.org/t/a-bunch-of-core-functions-should-be-inline-always/14173) `UnsafeCell::get` doesn't get inlined. Presumably a built-in language feature would not have this issue. This kind of thing has lead me to wonder if other features are better off with dedicated syntax, e.g. placement new.

---

_[View the full topic](https://internals.rust-lang.org/t/add-rustc-flag-to-disable-mutable-no-aliasing-optimizations/14404)._
