At the top of every *.rs file (except lib.rs) 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?
At the top of every *.rs file (except lib.rs) 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?
The proper way would be to not do it
*
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}
).
https://stackoverflow.com/questions/25877285/how-to-disable-unused-code-warnings-in-rust
but with unused_imports
instead of dead_code
.
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::*;
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.