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

submodules can't access non-pub type names in parent modules #5238

Closed
jbclements opened this Issue Mar 5, 2013 · 3 comments

Comments

Projects
None yet
4 participants
@jbclements
Contributor

jbclements commented Mar 5, 2013

For type names only, submodules can't apparently see non-pub types defined in the parent module. So, this code:

struct Name { x : int }

mod test {
    use super::Name;

    #[test] fn f () {
        let a : Name = Name { x : 3};
    }    
}

... generates this error:

jclements-09740:/tmp clements> rust test /tmp/foo.rs
Running /usr/local/bin/rustc:
/tmp/foo.rs:4:8: 4:20 error: failed to resolve import: super::Name
/tmp/foo.rs:4     use super::Name;
                      ^~~~~~~~~~~~
error: failed to resolve imports
error: aborting due to 2 previous errors
@luqmana

This comment has been minimized.

Show comment
Hide comment
@luqmana

luqmana Jun 15, 2013

Member

Now it at least tells you that Name is private:

-> % rustc bar.rs
bar.rs:4:8: 4:19 error: unresolved import: found `Name` in `???` but it is private
bar.rs:4     use super::Name;
                 ^~~~~~~~~~~
bar.rs:4:8: 4:19 error: failed to resolve import `super::Name`
bar.rs:4     use super::Name;
                 ^~~~~~~~~~~
error: aborting due to 2 previous errors

Though, it doesn't need to display the error twice and could do better than ???.

Member

luqmana commented Jun 15, 2013

Now it at least tells you that Name is private:

-> % rustc bar.rs
bar.rs:4:8: 4:19 error: unresolved import: found `Name` in `???` but it is private
bar.rs:4     use super::Name;
                 ^~~~~~~~~~~
bar.rs:4:8: 4:19 error: failed to resolve import `super::Name`
bar.rs:4     use super::Name;
                 ^~~~~~~~~~~
error: aborting due to 2 previous errors

Though, it doesn't need to display the error twice and could do better than ???.

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Jul 2, 2013

Member

linking to #6143 for unified tracking of resolve

Member

pnkfelix commented Jul 2, 2013

linking to #6143 for unified tracking of resolve

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Sep 19, 2013

Member

Closing as a dupe of #8215, this would be allowed with the rules in that bug.

Member

alexcrichton commented Sep 19, 2013

Closing as a dupe of #8215, this would be allowed with the rules in that bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment