'How to pass rustc flags 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?
Solution 1:[1]
You can disable dead code warnings by modifying config.toml file. if file doesn't exists create one as below locations.
Windows: %USERPROFILE%\.cargo\config.toml
Unix: $HOME/.cargo/config.toml
Then add below line
[target.'cfg(target_family = "windows")']
rustflags = ["-Adead_code"]
If you dont want to see any unused variable warnings add below line
[target.'cfg(target_family = "windows")']
rustflags = ["-Aunused"]
Don't forget to disable these before Production :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kargat TTT |
