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

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

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

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

jbclements opened this issue Mar 5, 2013 · 3 comments
Labels
A-resolve Area: Name resolution

Comments

@jbclements
Copy link
Contributor

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
Copy link
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
Copy link
Member

pnkfelix commented Jul 2, 2013

linking to #6143 for unified tracking of resolve

@alexcrichton
Copy link
Member

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

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 4, 2020
Changes:
````
Rustup to rust-lang#69506
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
add test for rust-lang#5238
````
bors added a commit that referenced this issue Mar 4, 2020
submodules: update clippy from 8b7f7e6 to 74eae9d

Changes:
````
Rustup to #69506
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
add test for #5238
````

Makes clippy tests pass again.

r? @oli-obk
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 4, 2020
Changes:
````
Apply suggestions from code review
Simplify if_chain.
Move NumericLiteral to its own module.
Included binary and octal cases.
Resolve false positives for hex int cast.
Test for unnecessary_cast of hex int literal.
run-rustfix
Lint `if let Some` in question_mark lint
Add restrictive pat use in full binded struct
Update test case answers to match cargo dev fmt
Ran cargo dev fmt
Rustup to rust-lang#69506
Recommended changes from flip1995
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
Fix one last test issue
Refactor suggested by krishna-veerareddy
Fixed compile error from merging
Changed test output to reflect cargo fmt
Run cargo dev fmt
Finished checking for cases of absolute values
add test for rust-lang#5238
Some bugfixing
Created floating point abs lint and test, but not yet run
````
bors added a commit that referenced this issue Mar 5, 2020
submodules: update clippy from 8b7f7e6 to 74eae9d

Changes:
````
Rustup to #69506
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
add test for #5238
````

Makes clippy tests pass again.

r? @oli-obk
bors pushed a commit to rust-lang-ci/rust that referenced this issue May 2, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name resolution
Projects
None yet
Development

No branches or pull requests

4 participants