Closed
Description
Because #[test]
marks tests as public so that they can be reexported (avoiding E0364), they can cause namespace pollutions that only occur in test builds.
Minimal repro:
mod A {
#[test]
fn foo() {}
}
mod B {
pub fn foo() -> bool {
true
}
}
use B::foo;
use A::*;
fn conflict() {
let x: bool = foo();
}
In a normal build, the only foo
in scope is B::foo
, but in a test build A::foo
will shadow it. And produce the following error:
error[E0308]: mismatched types
--> ./test.rs:20:19
|
20 | let x: bool = foo();
| ^^^^^ expected bool, found ()
|
= note: expected type `bool`
found type `()`