At the root of my project I have
#![warn(clippy::as_conversions)]
#![warn(clippy::unwrap_used)]
And while this is useful, in almost every single test module I have to manually disable those warnings again. Would be nice if there was a simple global solution I could specify somewhere in Cargo.toml to skip doing this for tests.
There's allow-unwrap-in-tests , but can't find anything regarding the as_conversions lint.
1 Like
Why putting tests into separate submodule and attaching clippy configuration to that submodule doesn't suit you?
It does, this is what I do actually!
The problem is that I have this written like 10 times, and I wonder whether there is a better way:
#[cfg(test)]
mod test {
#![allow(clippy::as_conversions)]
#![allow(clippy::unwrap_used)]
...
}
Would #![cfg_attr(not(test), warn(...))] instead of just #![warn(...)] do what you want?
5 Likes
system
Closed
August 24, 2025, 6:57pm
7
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.