I am trying to disable dead code warnings. I tried the following
cargo build -- -A dead_code
➜ rla git:(master) ✗ cargo build -- -A dead_code error: Invalid arguments.
So I am wondering how would I pass rustc arguments to cargo?
I am trying to disable dead code warnings. I tried the following
cargo build -- -A dead_code
➜ rla git:(master) ✗ cargo build -- -A dead_code error: Invalid arguments.
So I am wondering how would I pass rustc arguments to cargo?
You can pass flags through Cargo by several different means:
cargo rustc
, which only affects your crate and not its dependencies.RUSTFLAGS
environment variable, which affects dependencies as well.-C lto
and-C panic=abort
can be specified in theCargo.toml
file..cargo/config
using one of therustflags=
keys.However, in your specific case of configuring lints, you don't need to use compiler flags; you can also enable and disable lints directly in the source code using attributes. This may in fact be a better option as it's more robust, more targeted, and doesn't require you to alter your build system setup:
See also: