Do not show warnings

How to set up cargo to stop seeing warnings (during compilation)?

On Linux or Mac:

RUSTFLAGS=-Awarnings cargo build


$env:RUSTFLAGS = '-Awarnings'; 
cargo build

You can also add this to the top of the file you wish to disable warnings in:



I strongly suggest being more targeted about which ones you hide, as a bunch of them are very important.

Consider, for example,

#![cfg_attr(test, allow(dead_code))]

if you want to hide the warnings that things aren't used yet while you're in a cargo test iteration loop.

1 Like