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

Projects
None yet
8 participants
@jseyfried
Copy link
Contributor

jseyfried commented Feb 2, 2016

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 jseyfried force-pushed the jseyfried:fix_extern_crate_visibility branch from eb4e401 to 794df1d Feb 2, 2016

@jseyfried

This comment has been minimized.

Copy link
Contributor Author

jseyfried commented Feb 2, 2016

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 2, 2016

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 jseyfried:fix_extern_crate_visibility branch 2 times, most recently from 9d5ef32 to 9f6dd8e Feb 2, 2016

@jseyfried

This comment has been minimized.

Copy link
Contributor Author

jseyfried commented Feb 2, 2016

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

@jseyfried jseyfried force-pushed the jseyfried:fix_extern_crate_visibility branch 6 times, most recently from cce80e7 to 2168764 Feb 2, 2016

@nrc

This comment has been minimized.

Copy link
Member

nrc commented 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);

This comment has been minimized.

@nrc

nrc Feb 3, 2016

Member

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

This comment has been minimized.

@nrc

nrc Feb 3, 2016

Member

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


mod foo {
extern crate core;
pub use self::core as reexported_core; // Check that private extern crates can be reexported

This comment has been minimized.

@nrc

nrc Feb 3, 2016

Member

this should be a warning right?

This comment has been minimized.

@petrochenkov

petrochenkov Feb 3, 2016

Contributor

The private_in_public warning is reported during lint pass, much later than resolve.
It looks like it's tested separately in private-variant-and-crate-reexport.rs.

@nrc

This comment has been minimized.

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

This comment has been minimized.

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)]

This comment has been minimized.

@petrochenkov

petrochenkov Feb 3, 2016

Contributor

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.

This comment has been minimized.

@jseyfried

jseyfried Feb 4, 2016

Author Contributor

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

This comment has been minimized.

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 jseyfried force-pushed the jseyfried:fix_extern_crate_visibility branch from 73e8496 to f722e31 Feb 5, 2016

@jseyfried

This comment has been minimized.

Copy link
Contributor Author

jseyfried commented Feb 6, 2016

This also closes #22146.

@jseyfried jseyfried force-pushed the jseyfried:fix_extern_crate_visibility branch from f722e31 to 44d605c Feb 6, 2016

@bors

This comment has been minimized.

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 jseyfried:fix_extern_crate_visibility branch 2 times, most recently from ea0b0d5 to 3acbd2f Feb 11, 2016

@bors

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

nrc commented Feb 11, 2016

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

bors added a commit that referenced this pull request Feb 25, 2016

Auto merge of #31362 - jseyfried:fix_extern_crate_visibility, r=nikom…
…atsakis

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.
@bors

This comment has been minimized.

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

Rollup merge of rust-lang#31362 - jseyfried:fix_extern_crate_visibili…
…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 added a commit that referenced this pull request Feb 25, 2016

bors added a commit that referenced this pull request Feb 25, 2016

Auto merge of #31362 - jseyfried:fix_extern_crate_visibility, r=nikom…
…atsakis

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.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 25, 2016

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

@bors

This comment has been minimized.

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

bors added a commit that referenced this pull request Feb 25, 2016

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Feb 25, 2016

@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

1 of 2 checks passed

homu Test failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@llogiq llogiq referenced this pull request Feb 28, 2016

Closed

TWIR 120's CotW + PRs #174

@jseyfried jseyfried deleted the jseyfried:fix_extern_crate_visibility branch Mar 25, 2016

@bvssvni bvssvni referenced this pull request Apr 6, 2016

Closed

Disable CI for repos that break on stable #1050

5 of 5 tasks complete

@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
You can’t perform that action at this time.