Skip to content

extern crate is always treated as pub within the crate, but is not visible outside it; pub extern crate makes no difference #26775

Closed
@brson

Description

@brson

Two examples:

#![feature(core)]
#![crate_type = "lib"]
pub extern crate core;

That is accepted but core cannot be accessed from outside the crate.

#![feature(core)]
#![crate_type = "lib"]

mod foo {
    extern crate core;
    // behaves identically
    // pub extern crate core;
}

pub use foo::core;

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.

Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyA-visibilityArea: Visibility / privacyP-highHigh priorityT-langRelevant to the language team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions