Closed
Description
With this code:
fn main() { }
#[cfg(test)]
mod test_helpers {
pub(crate) trait Doubler {
fn doubled(&self) -> Self;
}
impl Doubler for u8 {
fn doubled(&self) -> u8 { self * 2 }
}
}
#[cfg(test)]
mod tests {
use ::test_helpers::Doubler;
mod inner {
use super::*;
#[test]
fn test_doubler() {
assert_eq!(21u8.doubled(), 42);
}
}
}
...I get the following warning when running cargo test
:
warning: unused import: `::test_helpers::Doubler`
--> src/main.rs:16:9
|
16 | use ::test_helpers::Doubler;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
If the warning is correct, I should be able to remove it and the code should still work. But of course if I remove the import, the follwing happens:
warning: unused import: `super::*`
--> src/main.rs:17:13
|
17 | use super::*;
| ^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
error[E0599]: no method named `doubled` found for type `u8` in the current scope
--> src/main.rs:21:29
|
21 | assert_eq!(21u8.doubled(), 42);
| ^^^^^^^
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
candidate #1: `use test_helpers::Doubler;`