Closed
Description
Summary
mod bar;
mod foo;
#[cfg(test)]
mod tests;
use bar::Trait;
pub fn fun() {}
I believe clippy should not dislike this code. Declaring modules at the top of the file is extremely common practice. People disagree on whether mod
goes before or after use
, but both of those ways are way more common than putting mod
last in a file.
Lint Name
items_after_test_module
Reproducer
// src/lib.rs
#[cfg(test)]
mod tests;
pub fn f() {}
// src/tests.rs (empty)
$ cargo clippy --tests
warning: items were found after the testing module
--> src/lib.rs:2:1
|
2 | / mod tests;
3 | |
4 | | pub fn f() {}
| |_____________^
|
= help: move the items to before the testing module was defined
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_test_module
= note: `#[warn(clippy::items_after_test_module)]` on by default
Version
rustc 1.71.0-nightly (f5559e338 2023-04-24)
binary: rustc
commit-hash: f5559e338256f17ada6d82b429acc2dbd8facc9c
commit-date: 2023-04-24
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2
Additional Labels
No response