Allow unused "use super::*" everywhere

At the top of every *.rs file (except I have

use super::*

sometimes, this results in a warning when it actually isn’t needed

Is there a way to set a global crate wide “allow unused use super::*” everywhere?

1 Like

The proper way would be to not do it :wink:

* imports are not considered as good, because you also pull in unwanted stuff which can result in confusing error messages (image doing use std::io::* and you want to return a Result<(), MyError> somewhere… won’t work).

Also only include what you really need and name it! (e.g. std::io::{Read, Seek}).

but with unused_imports instead of dead_code.

1 Like

I support this. I wanted to fix a gotcha in the default mod tests {} template, but it causes this warning:

@hellow : Perhaps this is an XY problem.

My goal is not to import std::io::* – and I don’t use use *, except in the context of super::*.

What I have is – within a single crate, I want pub structs defined within the crate to be visible everywhere. That’s the main thing I’m using the “super::*” everywhere for.

Perhaps a better solution is to use something like “use crate::*” ?

You could make yourself a prelude module that re-exports things you want to use everywhere, and then:

#[allow(unused)] use crate::prelude::*;