-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
extern crate
is always treated as pub
within the crate, but is not visible outside it; pub extern crate
makes no difference
#26775
Comments
Also see #21757. |
triage: P-high We should nail this down. I'm assigning this to @nrc since iirc he last touched the privacy code. ;) |
(any reason we can't just ... make Update: (with a warning cycle in the release series, of course) Update 2: Hmm, I guess I missed the point that it can also be reexported, so making |
@pnkfelix Making it illegal might still be a reasonable stop-gap if it looks like we won't fix the problem for a while. |
Temporary 'fix' for rust-lang#26775
Temporary 'fix' for rust-lang#26775
Can this be made into a hard error on nightly now? |
Should we do a crater run? (with this marked as error) Advice: if we do, please only make it an error if cap-lints is not provided. |
This has reached stable now, so I'd at least be fine going to a hard error! (pending crater) |
See #29654 for a more breakage-prone issue with |
extern crate
is always treated as pub
within the crate, but is not visible outside it; pub extern crate
makes no difference
I was looking at this today. Let me get specific with the issues:
The RFC is a little vague - it states that So, I thought, lets make
If It seems the best solution is to treat Alternatively, we could probably leave things as is for now, perhaps carry on with the plan to make cc @petrochenkov since he has been looking at privacy. |
and cc @rust-lang/lang |
@nrc for what it's worth, the semantic I intended in the RFC was formulated under the wrong assumption that private Since I see that aspect of Some background: |
@nrc and I discussed a bit today. My feeling is that:
|
I’ve been using this pattern to simulate pub mod tendril {
extern crate tendril;
pub use tendril::*;
} |
…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.
With rust 1.7, the following warning was being emitted by the compiler: warning: `pub extern crate` does not work as expected and should not be used. Likely to become an error. Prefer `extern crate` and `pub use`. Based on rust-lang/rust#26775 it appears that this change is the current best approach for properly exporting the libc dependency so it may be used outside of nix. Signed-off-by: Paul Osborne <osbpau@gmail.com>
With rust 1.7, the following warning was being emitted by the compiler: warning: `pub extern crate` does not work as expected and should not be used. Likely to become an error. Prefer `extern crate` and `pub use`. Based on rust-lang/rust#26775 it appears that the warning in 1.7 which was to be escalated to an error is going away but in older versions of rust it is still the case that `pub extern crate` will not work as expected. Instead, we use a somewhat creative hack to export the libc root as a module in nix. Down the line, it may make sense to either eliminate the need to export libc (by chaning the ioctl macros) or to move toward deprecated older versions of rustc. Signed-off-by: Paul Osborne <osbpau@gmail.com>
With rust 1.7, the following warning was being emitted by the compiler: warning: `pub extern crate` does not work as expected and should not be used. Likely to become an error. Prefer `extern crate` and `pub use`. Based on rust-lang/rust#26775 it appears that the warning in 1.7 which was to be escalated to an error is going away but in older versions of rust it is still the case that `pub extern crate` will not work as expected. Instead, we use a somewhat creative hack to export the libc root as a module in nix. Down the line, it may make sense to either eliminate the need to export libc (by chaning the ioctl macros) or to move toward deprecated older versions of rustc. Signed-off-by: Paul Osborne <osbpau@gmail.com>
libc: re-export libc properly With rust 1.7, the following warning was being emitted by the compiler: warning: `pub extern crate` does not work as expected and should not be used. Likely to become an error. Prefer `extern crate` and `pub use`. Based on rust-lang/rust#26775 it appears that this change is the current best approach for properly exporting the libc dependency so it may be used outside of nix. Signed-off-by: Paul Osborne <osbpau@gmail.com>
Two examples:
That is accepted but
core
cannot be accessed from outside the crate.That is accepted and reexports
core
.In other words,
extern crate
is always public to other modules, but can never be made public to other crates.There are no tests for
pub extern crate
so I suspect this is not intentional.The text was updated successfully, but these errors were encountered: