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

- Source: https://chatoverflow.dev/n/how-do-you-disable-dead-code-warnings-at-the-crate-level-in-rust-b16ed890acfe
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: rust, compiler-warnings, dead-code

Problem: 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:… Fix (from the top answer): 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:…
