-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify error messages caused by re-exporting
pub(crate)
visibility…
… to outside
- Loading branch information
1 parent
d22dd65
commit 33ab512
Showing
11 changed files
with
334 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
fn f1() {} | ||
enum E1 { V } | ||
struct S1 { | ||
#[rustfmt::skip] | ||
bar: i32, | ||
} | ||
mod m1 { | ||
pub use ::f1; //~ ERROR `f1` is only public within the crate, and cannot be re-exported outside | ||
pub use ::S1; //~ ERROR `S1` is only public within the crate, and cannot be re-exported outside | ||
pub use ::E1; //~ ERROR `E1` is only public within the crate, and cannot be re-exported outside | ||
pub use ::E1::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside | ||
} | ||
|
||
pub(crate) fn f2() {} | ||
pub(crate) enum E2 { | ||
V | ||
} | ||
pub(crate) struct S2 { | ||
#[rustfmt::skip] | ||
bar: i32, | ||
} | ||
mod m2 { | ||
pub use ::f2; //~ ERROR `f2` is only public within the crate, and cannot be re-exported outside | ||
pub use ::S2; //~ ERROR `S2` is only public within the crate, and cannot be re-exported outside | ||
pub use ::E2; //~ ERROR `E2` is only public within the crate, and cannot be re-exported outside | ||
pub use ::E2::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside | ||
} | ||
|
||
mod m3 { | ||
pub(crate) fn f3() {} | ||
pub(crate) enum E3 { | ||
V | ||
} | ||
pub(crate) struct S3 { | ||
#[rustfmt::skip] | ||
bar: i32, | ||
} | ||
} | ||
pub use m3::f3; //~ ERROR `f3` is only public within the crate, and cannot be re-exported outside | ||
pub use m3::S3; //~ ERROR `S3` is only public within the crate, and cannot be re-exported outside | ||
pub use m3::E3; //~ ERROR `E3` is only public within the crate, and cannot be re-exported outside | ||
pub use m3::E3::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside | ||
|
||
pub(self) fn f4() {} | ||
pub use ::f4 as f5; //~ ERROR `f4` is only public within the crate, and cannot be re-exported outside | ||
|
||
pub mod m10 { | ||
pub mod m { | ||
pub(super) fn f6() {} | ||
pub(crate) fn f7() {} | ||
pub(in crate::m10) fn f8() {} | ||
} | ||
pub use self::m::f6; //~ ERROR `f6` is private, and cannot be re-exported | ||
pub use self::m::f7; //~ ERROR `f7` is only public within the crate, and cannot be re-exported outside | ||
pub use self::m::f8; //~ ERROR `f8` is private, and cannot be re-exported | ||
} | ||
pub use m10::m::f6; //~ ERROR function `f6` is private | ||
pub use m10::m::f7; //~ ERROR `f7` is only public within the crate, and cannot be re-exported outside | ||
pub use m10::m::f8; //~ ERROR function `f8` is private | ||
|
||
pub mod m11 { | ||
pub(self) fn f9() {} | ||
} | ||
pub use m11::f9; //~ ERROR function `f9` is private | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -0,0 +1,220 @@ | ||
error[E0364]: `f1` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:8:13 | ||
| | ||
LL | pub use ::f1; | ||
| ^^^^ | ||
| | ||
note: consider marking `f1` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:8:13 | ||
| | ||
LL | pub use ::f1; | ||
| ^^^^ | ||
|
||
error[E0365]: `S1` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:9:13 | ||
| | ||
LL | pub use ::S1; | ||
| ^^^^ re-export of crate public `S1` | ||
| | ||
= note: consider declaring type or module `S1` with `pub` | ||
|
||
error[E0365]: `E1` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:10:13 | ||
| | ||
LL | pub use ::E1; | ||
| ^^^^ re-export of crate public `E1` | ||
| | ||
= note: consider declaring type or module `E1` with `pub` | ||
|
||
error[E0364]: `V` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:11:13 | ||
| | ||
LL | pub use ::E1::V; | ||
| ^^^^^^^ | ||
| | ||
note: consider marking `V` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:11:13 | ||
| | ||
LL | pub use ::E1::V; | ||
| ^^^^^^^ | ||
|
||
error[E0364]: `f2` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:23:13 | ||
| | ||
LL | pub use ::f2; | ||
| ^^^^ | ||
| | ||
note: consider marking `f2` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:23:13 | ||
| | ||
LL | pub use ::f2; | ||
| ^^^^ | ||
|
||
error[E0365]: `S2` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:24:13 | ||
| | ||
LL | pub use ::S2; | ||
| ^^^^ re-export of crate public `S2` | ||
| | ||
= note: consider declaring type or module `S2` with `pub` | ||
|
||
error[E0365]: `E2` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:25:13 | ||
| | ||
LL | pub use ::E2; | ||
| ^^^^ re-export of crate public `E2` | ||
| | ||
= note: consider declaring type or module `E2` with `pub` | ||
|
||
error[E0364]: `V` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:26:13 | ||
| | ||
LL | pub use ::E2::V; | ||
| ^^^^^^^ | ||
| | ||
note: consider marking `V` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:26:13 | ||
| | ||
LL | pub use ::E2::V; | ||
| ^^^^^^^ | ||
|
||
error[E0364]: `f3` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:39:9 | ||
| | ||
LL | pub use m3::f3; | ||
| ^^^^^^ | ||
| | ||
note: consider marking `f3` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:39:9 | ||
| | ||
LL | pub use m3::f3; | ||
| ^^^^^^ | ||
|
||
error[E0365]: `S3` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:40:9 | ||
| | ||
LL | pub use m3::S3; | ||
| ^^^^^^ re-export of crate public `S3` | ||
| | ||
= note: consider declaring type or module `S3` with `pub` | ||
|
||
error[E0365]: `E3` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:41:9 | ||
| | ||
LL | pub use m3::E3; | ||
| ^^^^^^ re-export of crate public `E3` | ||
| | ||
= note: consider declaring type or module `E3` with `pub` | ||
|
||
error[E0364]: `V` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:42:9 | ||
| | ||
LL | pub use m3::E3::V; | ||
| ^^^^^^^^^ | ||
| | ||
note: consider marking `V` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:42:9 | ||
| | ||
LL | pub use m3::E3::V; | ||
| ^^^^^^^^^ | ||
|
||
error[E0364]: `f4` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:45:9 | ||
| | ||
LL | pub use ::f4 as f5; | ||
| ^^^^^^^^^^ | ||
| | ||
note: consider marking `f4` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:45:9 | ||
| | ||
LL | pub use ::f4 as f5; | ||
| ^^^^^^^^^^ | ||
|
||
error[E0364]: `f6` is private, and cannot be re-exported | ||
--> $DIR/crate-private-reexport.rs:53:13 | ||
| | ||
LL | pub use self::m::f6; | ||
| ^^^^^^^^^^^ | ||
| | ||
note: consider marking `f6` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:53:13 | ||
| | ||
LL | pub use self::m::f6; | ||
| ^^^^^^^^^^^ | ||
|
||
error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:54:13 | ||
| | ||
LL | pub use self::m::f7; | ||
| ^^^^^^^^^^^ | ||
| | ||
note: consider marking `f7` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:54:13 | ||
| | ||
LL | pub use self::m::f7; | ||
| ^^^^^^^^^^^ | ||
|
||
error[E0364]: `f8` is private, and cannot be re-exported | ||
--> $DIR/crate-private-reexport.rs:55:13 | ||
| | ||
LL | pub use self::m::f8; | ||
| ^^^^^^^^^^^ | ||
| | ||
note: consider marking `f8` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:55:13 | ||
| | ||
LL | pub use self::m::f8; | ||
| ^^^^^^^^^^^ | ||
|
||
error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside | ||
--> $DIR/crate-private-reexport.rs:58:9 | ||
| | ||
LL | pub use m10::m::f7; | ||
| ^^^^^^^^^^ | ||
| | ||
note: consider marking `f7` as `pub` in the imported module | ||
--> $DIR/crate-private-reexport.rs:58:9 | ||
| | ||
LL | pub use m10::m::f7; | ||
| ^^^^^^^^^^ | ||
|
||
error[E0603]: function `f6` is private | ||
--> $DIR/crate-private-reexport.rs:57:17 | ||
| | ||
LL | pub use m10::m::f6; | ||
| ^^ private function | ||
| | ||
note: the function `f6` is defined here | ||
--> $DIR/crate-private-reexport.rs:49:9 | ||
| | ||
LL | pub(super) fn f6() {} | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0603]: function `f8` is private | ||
--> $DIR/crate-private-reexport.rs:59:17 | ||
| | ||
LL | pub use m10::m::f8; | ||
| ^^ private function | ||
| | ||
note: the function `f8` is defined here | ||
--> $DIR/crate-private-reexport.rs:51:9 | ||
| | ||
LL | pub(in crate::m10) fn f8() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0603]: function `f9` is private | ||
--> $DIR/crate-private-reexport.rs:64:14 | ||
| | ||
LL | pub use m11::f9; | ||
| ^^ private function | ||
| | ||
note: the function `f9` is defined here | ||
--> $DIR/crate-private-reexport.rs:62:5 | ||
| | ||
LL | pub(self) fn f9() {} | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 20 previous errors | ||
|
||
Some errors have detailed explanations: E0364, E0365, E0603. | ||
For more information about an error, try `rustc --explain E0364`. |
Oops, something went wrong.