Skip to content
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

unresolved import using separate files, but not mod statements #26873

Closed
durka opened this issue Jul 8, 2015 · 2 comments · Fixed by #30408
Closed

unresolved import using separate files, but not mod statements #26873

durka opened this issue Jul 8, 2015 · 2 comments · Fixed by #30408
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@durka
Copy link
Contributor

durka commented Jul 8, 2015

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
$
@durka
Copy link
Contributor Author

durka commented Jul 8, 2015

cc @TheNeikos

@apasel422
Copy link
Contributor

This appears to work now.

@apasel422 apasel422 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 8, 2015
durka added a commit to durka/rust that referenced this issue Dec 16, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Dec 16, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Dec 17, 2015
durka added a commit to durka/rust that referenced this issue Dec 18, 2015
bors added a commit that referenced this issue Dec 19, 2015
I think we can close #26873 with these tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants