# RFC use \`–cfg reduce\_unsafe\` to signal preference of safe code over performance

**URL:** <https://internals.rust-lang.org/t/rfc-use-cfg-reduce-unsafe-to-signal-preference-of-safe-code-over-performance/11648>\
**Category:** Uncategorized\
**Created:** [January 18, 2020, 12:09am UTC](https://internals.rust-lang.org/t/rfc-use-cfg-reduce-unsafe-to-signal-preference-of-safe-code-over-performance/11648 "2020-01-18T00:09:45Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Ixrec](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ixrec/32/6754_2.png) [@Ixrec](https://internals.rust-lang.org/u/Ixrec)\
**Post date:** [January 18, 2020, 11:59am UTC](https://internals.rust-lang.org/t/rfc-use-cfg-reduce-unsafe-to-signal-preference-of-safe-code-over-performance/11648/8 "2020-01-18T11:59:17Z")

</div>

I do think that this proposal _by itself_ doesn't really make any sense. Either the crate author simply doesn't use unsafe, or they objectively need unsafe in an irreplaceable way, or they want unsafe and did all the due diligence to validate that it's sound so there's no benefit to disabling it, or they want unsafe and _won't_ do the due diligence... in which case they probably won't add this cargo feature.

Basically, the same argument as [[Pre-RFC] Cargo Safety Rails](https://internals.rust-lang.org/t/pre-rfc-cargo-safety-rails/5535/25) and [Crate capability lists](https://internals.rust-lang.org/t/crate-capability-lists/8933/15). It's a pretty fundamanetal and general problem with all of the "less unsafe everywhere" proposals we've seen so far.

For this specific suggestion, the only scenario where it would even make sense to me is:

- the soundness of some code is fundamentally unclear even if you've done your due diligence, and
- there's a safe alternative for whatever the code's doing, and
- for whatever reason, the safe alternative is not simply another crate.

Offhand, I'm not aware of a single example of all three. `arrayvec` is probably worth getting out of your dep tree if you can, but IIUC the separate crate `tinyvec` already covers the subset of use cases that don't fundamentally require unsafe. Pointer offsetting is probably the single biggest example of "soundness unclear" in the ecosystem today, but it's also famously impossible to do in current Rust without UB anyway, so we're stuck with waiting on a language change there. And so on.

---

_[View the full topic](https://internals.rust-lang.org/t/rfc-use-cfg-reduce-unsafe-to-signal-preference-of-safe-code-over-performance/11648)._
