How do you disable dead code warnings at the crate level in Rust?
Full error message
While tinkering in Rust, I repeatedly encountered a lot of dead code warnings that made it difficult to focus. I tried using the outer attribute #[allow(dead_code)], but it only silences one warning at a time.
struct SemanticDirection;
fn main() {}
warning: struct `SemanticDirection` is never constructed
--> src\main.rs:1:8
|
1 | struct SemanticDirection;
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
How do I disable these warnings at the crate level?Solutionsource: stackoverflow \u2197
You can either: Add an allow attribute on a struct, module, function, etc.: #[allow(dead_code)] struct SemanticDirection; Add an allow as a crate-level attribute; notice the !: #![allow(dead_code)] Pass it to rustc: rustc -A dead_code main.rs Pass it using cargo via the RUSTFLAGS environment variable: RUSTFLAGS="$RUSTFLAGS -A dead_code" cargo build
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/a0bceafb6f2f22ff3c4c7580b9e02e559edbccfeb8bab98ab3e4b5f9f78a9a86hash \u00b7 a0bceafb6f2f22ff3c4c7580b9e02e559edbccfeb8bab98ab3e4b5f9f78a9a86