-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryT-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.Relevant to the dev-tools subteam, which will review and decide on the PR/issue.
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 `()`
sunjay and estebank
Metadata
Metadata
Assignees
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryT-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.Relevant to the dev-tools subteam, which will review and decide on the PR/issue.