I was following the advice about Test Organization for submodules in integration tests and was surprised to see warnings for unused code when I added another test file.
Here's a minimal reproduction:
// file: tests/common/mod.rs
pub struct A;
// file: tests/a.rs
mod common;
#[test]
fn a() {
todo!()
}
// file: tests/b.rs
mod common;
#[test]
fn b() {
let _value = common::A {};
}
The compiler protests and says that A
is never constructed, but the error disappears when I delete a.rs
. Am I missing something?
warning: struct `A` is never constructed
--> tests/common/mod.rs:1:12
|
1 | pub struct A;
| ^
|
= note: `#[warn(dead_code)]` on by default