rustcompiler-warningsdead-code

How do you disable dead code warnings at the crate level in Rust?


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?


Solution

  • You can either: