-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Glob importing causes unrelated compiler error #19179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Interestingly, the
Gives the same error, but commenting out |
I've been hitting this bug recently as well. Globs seem to interact strangely with non-public use statements. After some more experimentation I've reduced my situation to this: pub mod a {
pub use self::aa::*;
pub mod aa {
use b::YY; // comment out this...
pub struct XX;
}
}
pub mod b {
pub use self::bb::*;
pub mod bb {
use a::XX; // ...or this
pub struct YY;
}
} If either of the marked 'use' lines are commented out, it will compile, but will fail with unresolved import errors if both are present. If the globs are replaced by named imports, it compiles fine.
|
I might have found another variant of this error: pub mod a {
use ::b::B;
use std::*;
pub struct A {
i: isize
}
}
pub mod b {
use ::a::A;
use std::*;
pub struct B {
i: isize
}
} |
This has since been fixed, yay! |
As it doesn't seem to be fixed in beta (at least the one on play.rlo), the earliest release to get the fix would be 1.4? |
Yeah I think this landed relatively recently on nightly, so it should make its way into 1.4 |
Is this the cyclic globs issue? Does this mean we can finally clean up the import mess in |
Ignore assists with many results if grouping not supported
When using globs to import everything from a module where the module itself imports things from the global namespace causes an error:
That is to say, if
some_mod.rs
glob importsother_mod
andother_mod
imports something from::
(say,std
), the module cannot be found. If the glob import is replaced by manually importing every type, compilation succeeds.The error occurs on the line in the imported module that tries to import the module.
Test Case (link to Playpen):
Several months ago when I started learning Rust, this was actually the error that made modules so confusing to me in the beginning - I couldn't understand why sometimes (apparently when I used globs) I couldn't import
std
but instead I had to import every function and trait I wanted to use into my module's namespace.The text was updated successfully, but these errors were encountered: