I have a Rust project folder structure that contains an executable and a shared C-compatible library that are both build using the same sources. The Cargo.toml
manifest file looks like:
[package]
name = "foo-bar"
version = "0.1.0"
authors = ...
[lib]
name = "foo_bar"
crate-type = ["rlib", "cdylib"]
[[bin]]
name = "foo-bar"
test = false
doc = false
[dependencies]
...
As the executable is not using all of the code I get some "unused code" warnings when building the project with cargo build
. I could add #[allow(dead_code)]
lints all over my source code where necessary but that would disable them also when building the library target.
Is there a way to globally disable the "dead_code" lint only when compiling the (feature-wise smaller) bin
executable target but having it enabled for the lib
target?