Reputation: 6528
I have two files :
As you can see there is a circular dependency between these two modules. It seems like sometimes Rust supports circular dependencies, but for this case, the compiler throws errors:
src/json/mod.rs:1:25: 1:31 error: unresolved import (maybe you meant `ToJson::*`?)
src/json/mod.rs:1 pub use self::to_json::{ToJson};
^~~~~~
src/json/builder.rs:2:18: 2:22 error: unresolved import (maybe you meant `Json::*`?)
src/json/builder.rs:2 use json::json::{Json, JsonEvent, Array, Object}; //commenting this line solve the dependency error
[...]
The code is here in the branch json_mod. I tried to reproduce the problem in fewer lines of code, but the circular dependencies I created compiled correctly.
After the debugging, something like 400 errors are left — this is normal as I am in the process of a huge code refactoring (splitting one file of ~= 4000 line file into many files) and I still have a lot of work to do before making it work.
Upvotes: 5
Views: 4507
Reputation: 13792
Edit: Glorious news, the bug mentioned below is fixed! It's fixed in Rust 1.4 or later.
Glob imports (use foo::*
) have a known bug where they are incompatible with cyclic imports. I would try removing the glob imports in both affected modules.
Upvotes: 5