Skip to content

RFC: Use --cfg reduce_unsafe to signal preference of safe code over fast code #35

@WildCryptoFox

Description

@WildCryptoFox

(Cross posted on users.rust-lang.org and internals.rust-lang.org)

This complements #19 when the safe code can be produced but the performance cost is too high for a set of users willing to pay the safety cost.

Users could opt into this manually using RUSTFLAGS+='--cfg reduce_unsafe'; but I'd rather richer tooling - see below.

Crates branch on #[cfg(reduce_unsafe)].

Edit: I've implemented reduce_unsafe::(un)checked! macros with an example.


Alternatively a feature flag could be used instead and could be fine-grain for certain code.


Context: I've been using a custom RUSTC_WRAPPER and plan to promote this shell with Rust and add some more features. This complements cargo geiger, cargo crev and could be an early feature of cargo sandbox.

In addition to showing all unsafe code this also shows deprecation warnings and any other warnings or errors which are normally hidden because cargo uses --cap-lints allow (before RUSTFLAGS where it cannot be overridden without RUSTC_WRAPPER) to minimize damage of rustc's own changes.

(Use -Funsafe-code to catch uses of #[allow(unsafe_code)])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions