resolve: Remove visibility hacks for enum variants and trait items
Special treatment like this was necessary before `pub(restricted)` had been implemented and only two visibilities existed - `pub` and non-`pub`. Now it's no longer necessary and the desired behavior follows from `pub(restricted)`-style visibilities naturally assigned to enum variants and trait items.
This commit is contained in:
parent
b4b6b62e70
commit
8e74842089
8 changed files with 80 additions and 137 deletions
|
|
@ -1,15 +1,16 @@
|
|||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
#[deny(unused_imports)]
|
||||
mod rank {
|
||||
pub use self::Professor::*;
|
||||
//~^ ERROR enum is private and its variants cannot be re-exported
|
||||
//~^ ERROR glob import doesn't reexport anything
|
||||
pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
//~^ ERROR variant `JuniorGrade` is private and cannot be re-exported
|
||||
//~| ERROR variant `Full` is private and cannot be re-exported
|
||||
//~^ ERROR `JuniorGrade` is private, and cannot be re-exported
|
||||
//~| ERROR `Full` is private, and cannot be re-exported
|
||||
pub use self::PettyOfficer::*;
|
||||
//~^ ERROR enum is private and its variants cannot be re-exported
|
||||
//~^ ERROR glob import doesn't reexport anything
|
||||
pub use self::Crewman::*;
|
||||
//~^ ERROR enum is private and its variants cannot be re-exported
|
||||
//~^ ERROR glob import doesn't reexport anything
|
||||
|
||||
enum Professor {
|
||||
Adjunct,
|
||||
|
|
|
|||
|
|
@ -1,44 +1,51 @@
|
|||
error: variant `JuniorGrade` is private and cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:6:32
|
||||
error[E0364]: `JuniorGrade` is private, and cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: consider marking `JuniorGrade` as `pub` in the imported module
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^^^^^^^^
|
||||
...
|
||||
LL | enum Lieutenant {
|
||||
| --------------- help: consider making the enum public: `pub enum Lieutenant`
|
||||
|
||||
error: variant `Full` is private and cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:6:45
|
||||
error[E0364]: `Full` is private, and cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^
|
||||
|
|
||||
note: consider marking `Full` as `pub` in the imported module
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45
|
||||
|
|
||||
LL | pub use self::Lieutenant::{JuniorGrade, Full};
|
||||
| ^^^^
|
||||
|
||||
error: enum is private and its variants cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:4:13
|
||||
error: glob import doesn't reexport anything because no candidate is public enough
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:5:13
|
||||
|
|
||||
LL | pub use self::Professor::*;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | enum Professor {
|
||||
| -------------- help: consider making the enum public: `pub enum Professor`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:3:8
|
||||
|
|
||||
LL | #[deny(unused_imports)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: enum is private and its variants cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:9:13
|
||||
error: glob import doesn't reexport anything because no candidate is public enough
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:10:13
|
||||
|
|
||||
LL | pub use self::PettyOfficer::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | pub(in rank) enum PettyOfficer {
|
||||
| ------------------------------ help: consider making the enum public: `pub enum PettyOfficer`
|
||||
|
||||
error: enum is private and its variants cannot be re-exported
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:11:13
|
||||
error: glob import doesn't reexport anything because no candidate is public enough
|
||||
--> $DIR/issue-46209-private-enum-variant-reexport.rs:12:13
|
||||
|
|
||||
LL | pub use self::Crewman::*;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | crate enum Crewman {
|
||||
| ------------------ help: consider making the enum public: `pub enum Crewman`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0364`.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
mod m1 {
|
||||
pub use ::E::V; //~ ERROR variant `V` is private and cannot be re-exported
|
||||
pub use ::E::V; //~ ERROR `V` is private, and cannot be re-exported
|
||||
}
|
||||
|
||||
mod m2 {
|
||||
pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be re-exported
|
||||
pub use ::E::{V}; //~ ERROR `V` is private, and cannot be re-exported
|
||||
}
|
||||
|
||||
mod m3 {
|
||||
pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be re-exported
|
||||
pub use ::E::V::{self}; //~ ERROR `V` is private, and cannot be re-exported
|
||||
}
|
||||
|
||||
#[deny(unused_imports)]
|
||||
mod m4 {
|
||||
pub use ::E::*; //~ ERROR enum is private and its variants cannot be re-exported
|
||||
pub use ::E::*; //~ ERROR glob import doesn't reexport anything
|
||||
}
|
||||
|
||||
enum E { V }
|
||||
|
|
|
|||
|
|
@ -1,29 +1,48 @@
|
|||
error: variant `V` is private and cannot be re-exported
|
||||
error[E0364]: `V` is private, and cannot be re-exported
|
||||
--> $DIR/private-variant-reexport.rs:2:13
|
||||
|
|
||||
LL | pub use ::E::V;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: consider marking `V` as `pub` in the imported module
|
||||
--> $DIR/private-variant-reexport.rs:2:13
|
||||
|
|
||||
LL | pub use ::E::V;
|
||||
| ^^^^^^
|
||||
...
|
||||
LL | enum E { V }
|
||||
| ------ help: consider making the enum public: `pub enum E`
|
||||
|
||||
error: variant `V` is private and cannot be re-exported
|
||||
error[E0364]: `V` is private, and cannot be re-exported
|
||||
--> $DIR/private-variant-reexport.rs:6:19
|
||||
|
|
||||
LL | pub use ::E::{V};
|
||||
| ^
|
||||
|
|
||||
note: consider marking `V` as `pub` in the imported module
|
||||
--> $DIR/private-variant-reexport.rs:6:19
|
||||
|
|
||||
LL | pub use ::E::{V};
|
||||
| ^
|
||||
|
||||
error: variant `V` is private and cannot be re-exported
|
||||
error[E0365]: `V` is private, and cannot be re-exported
|
||||
--> $DIR/private-variant-reexport.rs:10:22
|
||||
|
|
||||
LL | pub use ::E::V::{self};
|
||||
| ^^^^
|
||||
| ^^^^ re-export of private `V`
|
||||
|
|
||||
= note: consider declaring type or module `V` with `pub`
|
||||
|
||||
error: enum is private and its variants cannot be re-exported
|
||||
--> $DIR/private-variant-reexport.rs:14:13
|
||||
error: glob import doesn't reexport anything because no candidate is public enough
|
||||
--> $DIR/private-variant-reexport.rs:15:13
|
||||
|
|
||||
LL | pub use ::E::*;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/private-variant-reexport.rs:13:8
|
||||
|
|
||||
LL | #[deny(unused_imports)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0364, E0365.
|
||||
For more information about an error, try `rustc --explain E0364`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// aux-build:variant-namespacing.rs
|
||||
|
||||
enum E {
|
||||
pub enum E {
|
||||
Struct { a: u8 },
|
||||
Tuple(u8),
|
||||
Unit,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue