rust-lang / cfg-if

A if/elif-like macro for Rust #[cfg] statements
Apache License 2.0
557 stars 40 forks source link

Forbid unsafe code #36

Closed ralpha closed 4 years ago

ralpha commented 4 years ago

cfg-if does not seem to use unsafe code, which is very good :)

To prevent this from ever happening, add following line to the top:

#![forbid(unsafe_code)]

of https://github.com/alexcrichton/cfg-if/blob/master/src/lib.rs

This will make the package green in https://github.com/rust-secure-code/cargo-geiger

Spaceface16518 commented 4 years ago

I'm not qualified to have an opinion on this but I remember there being an article somewhere that asked people not to use a global #![forbid(unsafe_code)] because it made it hard for the Rust developers to mark things as unsafe in the standard library (because it turns any unsafe code into a breaking change). I suggest this be taken into consideration, given how many crates use cfg-if.

alexcrichton commented 4 years ago

This crate doesn't use any unsafe code and it's highly unlikely to ever do so, but it's not in the contract of this crate that it will never use unsafe code so I'm not going to implement this.