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

glob imports ignore private items #23157

Closed
nrc opened this Issue Mar 8, 2015 · 7 comments

Comments

Projects
None yet
7 participants
@nrc
Copy link
Member

nrc commented Mar 8, 2015

This is a bug if the importing module should be able to see the private items. E.g.,

struct Foo;

mod sub {
    import super::*;

    type Bar = Foo; // Error: use of undeclared type name Foo
}

I think there is a backwards compatibility hazard here, because if there is already an item called Foo in sub then we currently get no error, but we ought to get a name clash (unless we allow shadowing in this case).

triage: I-nominated

@rust-highfive rust-highfive added this to the 1.0 beta milestone Mar 8, 2015

@nrc nrc removed this from the 1.0 beta milestone Mar 8, 2015

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 9, 2015

This is currently intentional, there is specific code in resolve to reject any imports of private items. The reason for this is that if an import itself is considered a private item the semantics get really weird very quickly.

For example, all modules import the prelude, so can I import Option from any module? (yes I'll get an error, but those seem like unusual semantics). I believe this is also done to assuage the implementation of cyclically importing everything from a module to another, although I'm less sure about this.

@nrc

This comment has been minimized.

Copy link
Member Author

nrc commented Mar 9, 2015

That seems reasonable in general, but I think the rule ought to be that globs only import accessible items, rather than public items, so that if a module imports a glob and has access to a private item it is still imported. I kind of see the argument for weirdness - but nothing that doesn't apply to pub use (I think).

Since there are no cycles in the 'can access private member' graph, it doesn't seem like it should make a difference wrt cyclicity.

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Mar 12, 2015

P-high, not 1.0.

@pnkfelix pnkfelix added P-medium and removed I-nominated labels Mar 12, 2015

@bltavares

This comment has been minimized.

Copy link
Contributor

bltavares commented Nov 24, 2015

Updating the code on the example:

struct Foo;

mod sub {
    use super::*;

    type Bar = Foo; // Error: use of undeclared type name Foo
}
@brson

This comment has been minimized.

Copy link
Contributor

brson commented Aug 25, 2016

@jseyfried Does #35894 fix this?

@jseyfried

This comment has been minimized.

Copy link
Contributor

jseyfried commented Aug 25, 2016

@brson Yeah, once #![feature(item_like_imports)] is stable, that is.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Aug 29, 2016

Depends on #35120.

bors added a commit that referenced this issue Nov 21, 2016

Auto merge of #37127 - jseyfried:stabilize_RFC_1560, r=nrc
Stabilize RFC 1560

Fixes #13598, fixes #23157, fixes #32303.
cc #35120
r? @nrc

@bors bors closed this in #37127 Nov 21, 2016

marmistrz added a commit to marmistrz/nix that referenced this issue Jul 31, 2017

marmistrz added a commit to marmistrz/nix that referenced this issue Aug 4, 2017

marmistrz added a commit to marmistrz/nix that referenced this issue Aug 7, 2017

justinas added a commit to justinas/gettext that referenced this issue Nov 1, 2018

Bump minimum Rust version once more
The test would not compile with 1.13 due to this bug:
rust-lang/rust#23157
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.