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

resolve: fix the visibility of extern crates #31362

Merged
merged 4 commits into from
Feb 25, 2016

Conversation

jseyfried
Copy link
Contributor

This PR changes the visibility of extern crate declarations to match that of items (fixes #26775).
To avoid breakage, the PR makes it a public_in_private lint to reexport a private extern crate, and it adds the lint inaccessible_extern_crate for uses of an inaccessible extern crate.

The lints can be avoided by making the appropriate extern crate declaration public.

@jseyfried
Copy link
Contributor Author

cc @nikomatsakis @petrochenkov

@petrochenkov
Copy link
Contributor

except that it allows private extern crate declarations to be re-exported. This exception considerably reduces breakage

It doesn't necessarily have to be a hard error immediately, you can mark such reexports with private_in_public warning (see https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/resolve_imports.rs#L504 for example).
It's not like this warning is going to become an error any time soon.

@jseyfried jseyfried force-pushed the fix_extern_crate_visibility branch 2 times, most recently from 9d5ef32 to 9f6dd8e Compare February 2, 2016 11:18
@jseyfried
Copy link
Contributor Author

@petrochenkov Good point, I added another commit making it a warning.

@jseyfried jseyfried force-pushed the fix_extern_crate_visibility branch 6 times, most recently from cce80e7 to 2168764 Compare February 3, 2016 00:34
@nrc
Copy link
Member

nrc commented Feb 3, 2016

cc @rust-lang/lang

@nrc nrc added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Feb 3, 2016
if name_binding.is_extern_crate() {
let msg = format!("extern crate `{}` is private, and cannot be reexported \
(error E0364), consider declaring with `pub`",
source);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move the consider... bit to a note please

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait, you can't it's a lint, nvm

@nrc
Copy link
Member

nrc commented Feb 3, 2016

The PR lgtm. I'll wait for a crater run and for the lang team to see this before giving r+ though.

@aturon
Copy link
Member

aturon commented Feb 3, 2016

Seems to match our previous decision on this question, so LGTM as well.

@@ -68,6 +68,7 @@ extern crate serialize as rustc_serialize; // used by deriving
#[cfg(test)]
extern crate test;

#[allow(private_in_public)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pub extern crate very buggy? I think it can be used here instead of suppressing the warning. It will report the "pub extern crate does not work as expected" warning during stage0, but that's ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, for some reason I thought that the warnings weren't ok.
pub extern crate works fine except that it is not visible to other crates (before this PR).

@bors
Copy link
Contributor

bors commented Feb 5, 2016

☔ The latest upstream changes (presumably #31386) made this pull request unmergeable. Please resolve the merge conflicts.

@jseyfried
Copy link
Contributor Author

This also closes #22146.

@bors
Copy link
Contributor

bors commented Feb 11, 2016

☔ The latest upstream changes (presumably #31461) made this pull request unmergeable. Please resolve the merge conflicts.

@jseyfried jseyfried force-pushed the fix_extern_crate_visibility branch 2 times, most recently from ea0b0d5 to 3acbd2f Compare February 11, 2016 08:05
@bors
Copy link
Contributor

bors commented Feb 11, 2016

☔ The latest upstream changes (presumably #31487) made this pull request unmergeable. Please resolve the merge conflicts.

@nrc
Copy link
Member

nrc commented Feb 11, 2016

@brson or @alexcrichton could we get a crater run for this PR please?

@bors
Copy link
Contributor

bors commented Feb 25, 2016

⌛ Testing commit 7ad7065 with merge f06ff1a...

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 25, 2016
…ty, r=nikomatsakis

This PR changes the visibility of extern crate declarations to match that of items (fixes rust-lang#26775).
To avoid breakage, the PR makes it a `public_in_private` lint to reexport a private extern crate, and it adds the lint `inaccessible_extern_crate` for uses of an inaccessible extern crate.

The lints can be avoided by making the appropriate `extern crate` declaration public.
@Manishearth Manishearth reopened this Feb 25, 2016
@bors
Copy link
Contributor

bors commented Feb 25, 2016

⌛ Testing commit 7ad7065 with merge 4a01bac...

@bors
Copy link
Contributor

bors commented Feb 25, 2016

💔 Test failed - auto-linux-64-nopt-t

bors added a commit that referenced this pull request Feb 25, 2016
@alexcrichton
Copy link
Member

@bors: retry

On Thu, Feb 25, 2016 at 12:28 AM, bors notifications@github.com wrote:

[image: 💔] Test failed - auto-linux-64-nopt-t
http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/8166


Reply to this email directly or view it on GitHub
#31362 (comment).

@bors bors merged commit 7ad7065 into rust-lang:master Feb 25, 2016
@jseyfried jseyfried deleted the fix_extern_crate_visibility branch March 25, 2016 22:53
@jseyfried jseyfried changed the title Resolve: Fix the visibility of extern crates resolve: Fix the visibility of extern crates Feb 14, 2017
@jseyfried jseyfried changed the title resolve: Fix the visibility of extern crates resolve: fix the visibility of extern crates Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants