mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
81f3ae8997
Clarify error messages caused by re-exporting `pub(crate)` visibility to outside This PR clarifies error messages and suggestions caused by re-exporting pub(crate) visibility outside the crate. Here is a small example ([Rust Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e2cd0bd4422d4f20e6522dcbad167d3b)): ```rust mod m { pub(crate) enum E {} } pub use m::E; fn main() {} ``` This code is compiled to: ``` error[E0365]: `E` is private, and cannot be re-exported --> prog.rs:4:9 | 4 | pub use m::E; | ^^^^ re-export of private `E` | = note: consider declaring type or module `E` with `pub` error: aborting due to previous error For more information about this error, try `rustc --explain E0365`. ``` However, enum `E` is actually public to the crate, not private totally—nevertheless, rustc treats `pub(crate)` and private visibility as the same on the error messages. They are not clear and should be segmented distinctly. By applying changes in this PR, the error message below will be the following message that would be clearer: ``` error[E0365]: `E` is only public to inside of the crate, and cannot be re-exported outside --> prog.rs:4:9 | 4 | pub use m::E; | ^^^^ re-export of crate public `E` | = note: consider declaring type or module `E` with `pub` error: aborting due to previous error For more information about this error, try `rustc --explain E0365`. ``` |
||
---|---|---|
.. | ||
bootstrap | ||
build_helper | ||
ci | ||
doc | ||
etc | ||
librustdoc | ||
llvm-project@f9b03d0e2d | ||
rustdoc-json-types | ||
test | ||
tools | ||
README.md | ||
stage0.json | ||
version |
This directory contains the source code of the rust project, including:
- The test suite
- The bootstrapping build system
- Various submodules for tools, like rustdoc, rls, etc.
For more information on how various parts of the compiler work, see the rustc dev guide.