Closed
Description
This code compiles:
//! lib.rs
mod A {
pub mod B {
use super::*;
pub struct S;
}
pub mod C {
use super::*;
use super::B::S;
pub struct T;
}
pub use self::C::T;
}
use A::*;
$ rustc --crate-type lib lib.rs -Awarnings
$
However, splitting the code into files causes compilation to fail:
//! lib.rs
mod A;
use A::*;
//! A/mod.rs
pub mod B;
pub mod C;
pub use self::C::T;
//! A/B.rs
use super::*;
pub struct S;
//! A/C.rs
use super::*;
use super::B::S;
pub struct T { i: i32 }
$ rustc --crate-type lib lib.rs -Awarnings
lib.rs:3:5: 3:10 error: unresolved import
lib.rs:3 use A::*;
^~~~~
A/mod.rs:4:9: 4:26 error: unresolved import
A/mod.rs:4 pub use self::C::T;
^~~~~~~~~~~~~~~~~
A/C.rs:1:5: 1:14 error: unresolved import
A/C.rs:1 use super::*;
^~~~~~~~~
A/B.rs:1:5: 1:14 error: unresolved import
A/B.rs:1 use super::*;
^~~~~~~~~
error: aborting due to 4 previous errors
$
I am not sure whether use C::T
or use self::C::T
is correct; regardless, replacing the latter with the former in A/mod.rs
produces a similar error:
$ rustc --crate-type lib lib.rs -Awarnings
A/mod.rs:4:9: 4:10 error: unresolved import `C::T`. Maybe a missing `extern crate C`?
A/mod.rs:4 pub use C::T;
^
error: aborting due to previous error
$