You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using use foo::{FooTypeA, FooTypeB}; and use foo; together, the compiler complains that use foo; is an unused import even when a call to something like foo::hello() exists. Removing use foo; gets rid of the warning and the crate compiles. However, the crate will fail to link (for example with --test) unless the use foo; is there.
It seems like the warning is a bug unless the intent is to have use foo::{FooTypeA, FooTypeB}; also bring in foo itself.
Here's a small crate that shows the example. This was originally found in rust-core-foundation.
Looking at the code, that's a genuinely unused import when not compiling with --test.
I ran into this when removing unused imports in the compiler, and you can prefix the import with #[cfg(test)] so that the import is only resolved when testing. Other options I've seen are to have a mod test which is cfg'd off, or just put the use in the function itself.
Allow `use super::*;` glob imports
changelog: Allow super::* glob imports
fixesrust-lang#5554fixesrust-lang#5569
A first pass at rust-lang#5554 - this allows all `use super::*` to pass, which may or may not be desirable. The original issue was around allowing test modules to import their entire parent modules - I'm happy to modify this to do that instead, may just need some guidance on how to implement that (I played around a bit with #[cfg(test)] but from what I can gather, clippy itself isn't in test mode when running, even if the code in question is being checked for the test target).
When using
use foo::{FooTypeA, FooTypeB};
anduse foo;
together, the compiler complains thatuse foo;
is an unused import even when a call to something likefoo::hello()
exists. Removinguse foo;
gets rid of the warning and the crate compiles. However, the crate will fail to link (for example with--test
) unless theuse foo;
is there.It seems like the warning is a bug unless the intent is to have
use foo::{FooTypeA, FooTypeB};
also bring in foo itself.Here's a small crate that shows the example. This was originally found in rust-core-foundation.
https://gist.github.com/metajack/5249056
The text was updated successfully, but these errors were encountered: