3 ms·
I know that I could probably find this out myself but is there a command-line switch that would make the use of unsafe {} a compile-time error? Of course the al
by johnisgood 7y ago
I know that I could probably find this out myself but is there a command-line switch that would make the use of unsafe {} a compile-time error? Of course the alternative is just a quick grep for it, but personally I would feel safer if the code did not compile at all in the presence of a compiler switch/flag and unsafe blocks.
- steveklabnik 7y agoSo, there is, but it only works for your code. You can do it via an attribute in the source (#![forbid(unsafe)]) or via a command line flag (cargo rustc -- -D unsafe). This will not check your dependencies. You can use other tools, like cargo-geiger https://github.com/anderejd/cargo-geiger https://github.com/anderejd/cargo-geiger to check your dependencies. And of course, at the lowest levels, doing anything useful requires unsafe, since your operating system doesn't expose a Rust API to do tasks.
- johnisgood 7y agoThank you! I will use that attribute wherever I can.