A program that list statistics related to usage of unsafe Rust code in a Rust crate and all its dependencies.
This cargo plugin is based on the code from two other projects: https://github.com/icefoxen/cargo-osha and https://github.com/sfackler/cargo-tree.
cargo install cargo-geiger
Cargo.toml
you want to analyze.cargo geiger
When and why to use unsafe Rust is out of scope for this project, it is simply a tool that provides information to aid auditing and hopefully to guide dependency selection. It is however the opinion of the author of this project that libraries choosing to abstain from unsafe Rust usage when possible should be promoted.
This project is an attempt to create pressure against unnecessary usage of unsafe Rust in public Rust libraries.
https://en.wikipedia.org/wiki/Geiger_counter
Unsafe code and ionizing radiation have something in common, they are both inevitable in some situations and both should preferably be safely contained!
build.rs
are probably not detected.#![forbid(unsafe_code)]
should be a reliable alternative (implemented since
0.6.0). Please see the changelog..rs
source
files, used by the build, declare #![forbid(unsafe_code)]
. Crates like
this will be printed in green..rs
file, used by the build, does not declare #[forbid(unsafe_code)]
. Crates
like this will be printed in the default terminal foreground color.cargo
, to the new crate
[geiger]. Main github issue: [#30].BUGFIX: Merge pull request [#33] from ajpaverd/windows_filepaths. Canonicalize file paths from walker.
Merge pull request [#38] from anderejd/updated-deps. Updated deps and fixed build errors.
Merge pull request [#28] from alexmaco/deps_upgrade. fix build on rust 1.30: upgrade petgraph to 0.4.13
Merge pull request [#29] from alexmaco/invalidutf8source. fix handling source files with invalid utf8: lossy conversion to string
--include-tests
. The test code is filted out by looking for the attribute
#[test]
on functions and #[cfg(test)]
on modules.rustc
calls and reads the .d
files generated by rustc
to
identify which .rs
files are used by the build. This allows a crate that
contains .rs
files with unsafe code usage to pass as "green" if the unsafe
code isn't used by the build.x/y
, where x
is the unsafe code used by the
build and y
is the total unsafe usage found in the crate.--compact
output format to avoid some code complexity. A new
and better compact mode can be added later if requested.--compact
.