-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
b4b6b62
commit 8e74842
Showing
8 changed files
with
80 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 29 additions & 22 deletions
51
src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// aux-build:variant-namespacing.rs | ||
|
||
enum E { | ||
pub enum E { | ||
Struct { a: u8 }, | ||
Tuple(u8), | ||
Unit, | ||
|