about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-01-06 18:07:47 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-02-10 22:46:44 +0300
commit8e748420896cfbf55e1a3cd8c51e4aba499cfb2d (patch)
treeeee48756780d18a754a875d4781218a0caa08b7d /src
parentb4b6b62e70f94c949b82f669498a925e3d4c3c2b (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs11
-rw-r--r--src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr51
-rw-r--r--src/test/ui/privacy/private-variant-reexport.rs9
-rw-r--r--src/test/ui/privacy/private-variant-reexport.stderr37
-rw-r--r--src/test/ui/variants/variant-namespacing.rs2
5 files changed, 69 insertions, 41 deletions
diff --git a/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs
index d54c9931479..8f9dc4bc945 100644
--- a/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs
+++ b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.rs
@@ -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,
diff --git a/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr
index b876bab6c54..d4d9b31ed83 100644
--- a/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr
+++ b/src/test/ui/privacy/issue-46209-private-enum-variant-reexport.stderr
@@ -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`.
diff --git a/src/test/ui/privacy/private-variant-reexport.rs b/src/test/ui/privacy/private-variant-reexport.rs
index 0722b815c14..ce1b0d321ca 100644
--- a/src/test/ui/privacy/private-variant-reexport.rs
+++ b/src/test/ui/privacy/private-variant-reexport.rs
@@ -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 }
diff --git a/src/test/ui/privacy/private-variant-reexport.stderr b/src/test/ui/privacy/private-variant-reexport.stderr
index 8e4c3452862..7a4c3234dbe 100644
--- a/src/test/ui/privacy/private-variant-reexport.stderr
+++ b/src/test/ui/privacy/private-variant-reexport.stderr
@@ -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`.
diff --git a/src/test/ui/variants/variant-namespacing.rs b/src/test/ui/variants/variant-namespacing.rs
index ceb7d274514..975e471fe34 100644
--- a/src/test/ui/variants/variant-namespacing.rs
+++ b/src/test/ui/variants/variant-namespacing.rs
@@ -1,6 +1,6 @@
 // aux-build:variant-namespacing.rs
 
-enum E {
+pub enum E {
     Struct { a: u8 },
     Tuple(u8),
     Unit,